-
-
Notifications
You must be signed in to change notification settings - Fork 442
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
feat(js_parser): support metavariables #3548
Conversation
d85b4c1
to
3303aa8
Compare
CodSpeed Performance ReportMerging #3548 will not alter performanceComparing Summary
|
Do you think it could make sense of using a more generic name such as |
Yeah, I’m fine with that. It seems we’ll use them for other purposes too anyway. |
What I fail to see is whether we are adding support for a specific metavariable— If we're adding support for a generic metavariable, then that's where the codegen comes into play. For example, we could define a The codegen will add any metavariable we will support, e.g.: css``
html``
grit``
graphql`` And we could go even farther by filtering the metavariables based on the language. For example, if we are generating the codegen for the CSS, we shouldn't add support for the |
From what I understand this approach should be reusable for the metavariables inside template literals as well, so I would say it's generic. @ah-yu , correct me if I'm wrong :) Of course it's less likely we will have JS template literals inside JS sources, which I think was the motivation the CSS parser was prepared first. So maybe this PR specifically is more beneficial towards the Grit implementation, although I expect it might even be reusable if we want to add support for HTML templates with JS snippets one day. Although that's still quite a ways out.
I'm not really sure where an
These are not actually metavariables though, they're merely template strings within which metavariables could be used. So what would happen for each of these template string kinds is that the respective parser gets invoked, with the option to parse metavariables enabled, but within that context you'll only need one kind of metavariable. So the CSS parser uses the CSS metavariable kind, the JS parser uses the JS metavariable kind, etc.. |
@Conaclos I will do the rename now ( |
Summary
Adds the ability to parse Grit metavariables to the JS parser.
I've also looked for opportunities to let the codegen take more out of our hands, but I have to admit I can't seem to find many. I did move some lexer helpers that were introduced with the CSS metavariables PR to the generic lexer.
I probably missed some places where metavariables could be allowed still, but I'd rather add those iteratively since this PR is already quite big.
Test Plan
Tests added.