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

Support Classic Handlebars #14

Open
1 task
alexlafroscia opened this issue Mar 7, 2021 · 5 comments
Open
1 task

Support Classic Handlebars #14

alexlafroscia opened this issue Mar 7, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@alexlafroscia
Copy link
Collaborator

alexlafroscia commented Mar 7, 2021

Glimmer and Handlebars have diverged syntactically in many ways; not only does Glimmer define plenty of things beyond Handlebars, Handlebars has some syntax that is not part of Glimmer.

It might be worth supporting those elements, even though they're not part of Glimmer specifically, in order to handle a few cases that are not currently handled.


  • Partial injection

    The > after the {{ indicated a partial will be injected in this location. Support would just require handling the > and highlighting the expression as a mustache_statement

    {{> partial }}
@alexlafroscia alexlafroscia added the enhancement New feature or request label Mar 7, 2021
@davidscotson
Copy link

I'm looking to use this for .mustache templates and I can see a few issues, but I'm not sure which would also be issues in other variants too and so maybe deserve their own issue, versus just being mentioned here:

  • multi-line comment blocks only seem to detect the first line
  • triple {{{ for unescaped content is detected as an error.

I guess a more general question is how this interacts with .css, .js and .html tree-sitter parsers, if I use :TSPlaygroundToggle then text attributes in plain HTML sections seem to get detected as concat statements. If I switch the filetype to .html then the same thing is highlighted as an attribute value, within a quoted attribute value inside an attribute. It even detects style tags as having CSS within them. It seems like ideally the mustache/handlebars/glimmer stuff would hand over to the HTML one as far as possible when the content is plain HTML, but I'm not sure how feasible that is.

@davidscotson
Copy link

From reading tree-sitter/tree-sitter-html#5 it sounds like the more basic, non-glimmer/ember usages might be easier done by a seperate treesitter plugin following the erb example. I might give that a go.

@davidscotson
Copy link

Reading your test cases, the multiline comment appears to be an intentional thing, requiring the {{!-- syntax for multi-line comments, so it seems it might be easier for me to start from scratch and write a simpler mustache tree-sitter parser, (particularly if I only start with the bits I actually use).

@bnomei
Copy link

bnomei commented Aug 22, 2021

{{> @partial this }} is a common pattern when using fractal.build. if this treesitter plugin could highlight the @ and this would be awesome.

@NullVoxPopuli
Copy link
Member

@bnomei would you be interested in submitting a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants