-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
WIP: Update handlebars syntax for Glimmer and Ember syntaxes #3099
Conversation
src/languages/handlebars.js
Outdated
className: 'template-tag', | ||
begin: /<:?/, | ||
end: />/, | ||
contains: [ OPENING_BLOCK_MUSTACHE_CONTENTS, BLOCK_PARAMS, KEYWORD_CONTENTS ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't put an empty block like KEYWORD_CONTENTS here, it'll do nothing because it has no match
or begin
tags. If you ant to match keywords here you'd put keywords at the top-level.
className: 'template-tag', | |
begin: /<:?/, | |
end: />/, | |
contains: [ OPENING_BLOCK_MUSTACHE_CONTENTS, BLOCK_PARAMS, KEYWORD_CONTENTS ] | |
className: 'template-tag', | |
keywords: // keywords go here | |
begin: /<:?/, | |
end: />/, | |
contains: [ OPENING_BLOCK_MUSTACHE_CONTENTS, BLOCK_PARAMS ] |
@nknapp Would you be around to help review this when it's ready? |
If you get overwhelmed here I'd suggest to start with smaller chunks (ie, try to accomplish these things a few at a time) vs a huge PR that does it all. For example you could perhaps clean up the keyword situation first, without trying to add any new tags, etc... so far the PR is "ok" (clean enough for review) but if it gets too complex then we'd ask you to break it into smaller pieces anyways just so we can see what you did and be able to properly review it, etc. But since this is your first commit and "idk what I'm doing" I'd suggest taking it slow and working in small chunks. (which can be more easily reviewed and merged - which will build momentum and a sense of achievement). Food for thought. |
You'll likely need to add $pattern back at some point... may want to review the commit log to see why it was added and what problem it's solving. |
33086b5
to
1a16272
Compare
Also, is this official handlebars are are these Ember and Glimmer specific extensions? |
@@ -324,6 +333,12 @@ export default function(hljs) { | |||
end: /\}\}/, | |||
keywords: 'else if' | |||
}, | |||
{ | |||
className: 'bulit_in', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo :-)
src/languages/handlebars.js
Outdated
Website: https://handlebarsjs.com | ||
Category: template | ||
Website: https://handlebarsjs.com, https://emberjs.com | ||
Category: common, template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert, this is not your decision to make - which languages are in our common
set. If you just want to add handlebars to the build your an do so on the console:
./tools/build -t node :common handlebars
Etc. Builds common + handlebars.
Also what is embers relationship to Handlebars?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also what is embers relationship to Handlebars?
ember has similar syntax, but has built a bunch of stuff on top, as a result, the handlebars syntax in highlight.js ~7 years out of date :(
(but that's why I'm making a PR!) :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a result, the handlebars syntax in highlight.js ~7 years out of date
I'm not sure that's a correct statement [in the general sense]. I know @nknapp put a lot of work into it just last year to improve it.
AFAIK Handlebar exists as it's own independent project and there are surely those using it outside of Ember - like our very own project, actually. So the question then becomes whether this is appropriate to be added to Handlebars at all or whether a separate Ember grammar may be needed. I'm curious if nknapp has any thoughts on that.
In any case I can certainly see how this would be helpful for Ember users, but if we decide it's not appropriate as part of Handlebars proper then it would need to be distributed as a 3rd party Ember grammar - rather than mixed with our existing support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's totally fair! Most editors have an ember-variant to use for hbs highlighting
@@ -205,7 +205,7 @@ export default function(hljs) { | |||
}; | |||
|
|||
const SUB_EXPRESSION_CONTENTS = hljs.inherit(HELPER_NAME_OR_PATH_EXPRESSION, { | |||
className: 'name', | |||
className: 'function', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure that your PR explanation justifies (visual) changes like this and explains why they are necessary...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can do!
In this particular case, helpers are functions (and take args), and not actually just a name, like you'd have with the name of a Component invocation.
Thanks for the early comments! these are helpful!!
I'll check it out 👍
handlebars doesn't have components, so about everything I'm doing is going to be on top of handlebars, but for ember and glimmer (they use the same hbs file extension though). I saw there was an HTMLBars syntax, but it looked like it was going to be removed. I can move all of this into a new ember/glimmer specific syntax, if that's desired and try extending from handlebars. |
I have a test template that I'm working through here in the developer.html: My plan was to get the whole thing looking correct before taking the PR out of draft. |
Correct, also it's only an alias of Handlebars at this point.
That is indeed the question. Though at that point it becomes a 3rd party module so I wouldn't worry about "extending" anything (you could, but we don't really encourage or support run-time dependencies)... at that point you'd just be "forking" the grammar essentially and then carrying it forward as Ember/Glimmer specific. But perhaps that's all you meant by "extending" in the first place. :-) |
I'm gonna move all this to a new file, called |
This definitely seems to seal the deal that this is an entirely separate grammar, not Handlebars (though I was already leaning that way in my thinking). At this point you'd be creating a 3rd party grammar module (in your own repository) so I'd check out our documentation on doing that: |
Cool! thanks for having all this documentation written up! |
It seemed that the handlebars syntax here is pretty old, this PR aims to update it to all the features currently available to Glimmer and Ember projects
Changes
name
tofunction
, because helpers are functions.Checklist
CHANGES.md