Open alexlafroscia opened 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.
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.
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).
{{> @partial this }}
is a common pattern when using fractal.build. if this treesitter plugin could highlight the @
and this
would be awesome.
@bnomei would you be interested in submitting a PR?
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 amustache_statement