ember-tooling / tree-sitter-glimmer

A TreeSitter grammar for Glimmer (HBS) templates
https://ember-tooling.github.io/tree-sitter-glimmer/
23 stars 3 forks source link

Support Classic Handlebars #14

Open alexlafroscia opened 3 years ago

alexlafroscia commented 3 years ago

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.


davidscotson commented 3 years ago

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:

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 commented 3 years ago

From reading https://github.com/tree-sitter/tree-sitter-html/issues/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 commented 3 years ago

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 commented 2 years ago

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

NullVoxPopuli commented 3 months ago

@bnomei would you be interested in submitting a PR?