Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Common] Adjust meta.embedded vs. meta.interpolation #4054

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

deathaxe
Copy link
Collaborator

@deathaxe deathaxe commented Oct 5, 2024

inspired by #3051

This commit aligns meta.embedded and meta.interpolation scopes across HTML and its template languages.

The rule of thumb being applied is:

  1. declarative syntaxes (CSS, JSON) or those executed at runtime (JS) are not scoped meta.embedded nor meta.interpolation. They are treated as belonging to HTML

    It's wrong value of <div style="..."> being scoped meta.interpolation as this is not what interpolation is.

  2. tags interpreted or executed by a pre-processor or template engine are scoped meta.embedded regardless they appear in normal text or strings.

    A template engine's interpreter does not know anything about HTML or any other top-level syntax. It just interprets embedded special tokens.

    Some engines such as php distinguish statements <?...?> and expressions <?= ...?> with the latter ones often used to expand to strings (acting like interpolation). Both are still scoped meta.embedded as distinction is not possible in all template syntaxes and some of them even provide additional real string interpolation constructs.

  3. only real string interpolations are scoped meta.interpolation, which most likely are part of an embedded templating language itself.

    ERB provides #{var} interpolation to be used everywhere, for instance.

inspired by sublimehq#3051

This commit aligns meta.embedded and meta.interpolation scopes across HTML
and its template languages.

The rule of thumb being applied is:

1. declarative syntaxes (CSS, JSON) or those executed at runtime (JS)
   are not scoped meta.embedded nor meta.interpolation.
   They are treated as belonging to HTML

   It's wrong value of `<div style="...">` being scoped `meta.interpolation`
   as this is not what interpolation is.

2. tags interpreted or executed by a pre-processor or template engine
   are scoped meta.embedded regardless they appear in normal text or strings.

   A template engine's interpreter does not know anything about HTML or any
   other top-level syntax. It just interprets `embedded` special tokens.

   Some engines such as php distinguish statements `<?...?>`
   and expressions `<?= ...?>` with the latter ones often used to expand to
   strings (acting like interpolation). Both are still scoped `meta.embedded`
   as distinction is not possible in all template syntaxes and some of them
   even provide additional real string interpolation constructs.

3. only real string interpolations are scoped meta.interpolation, which most
   likely are part of an embedded templating language itself.

   ERB provides `#{var}` interpolation to be used everywhere, for instance.
deathaxe added a commit to SublimeText/Liquid that referenced this pull request Oct 5, 2024
deathaxe added a commit to Sublime-Instincts/BetterJinja that referenced this pull request Oct 5, 2024
deathaxe added a commit to SublimeText/Mustache that referenced this pull request Oct 5, 2024
deathaxe added a commit to deathaxe/Twig that referenced this pull request Oct 6, 2024
Inline styles are no string interpolation and thus shouldn't be scoped as such.

related with sublimehq/Packages#4054
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant