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

Add parserOption to allow developers define what a mustache construct looks like #12

Open
tonyobanon opened this issue Mar 8, 2023 · 1 comment

Comments

@tonyobanon
Copy link

tonyobanon commented Mar 8, 2023

Many developers use handlebars to generate HTML markup. But the current syntax makes it impossible to use handlebars for static markup generation with frameworks like AMP and others because of the conflict in the syntax, For example: {{...}} has a special meaning in both handlebars and AMP

We need to have a new parserOption to allow developers to define the number of mustache braces the parser needs to find before processing it as a mustache construct (MustacheStatement, BlockStatement, DecoratorBlock, PartialStatement e.t.c).
For example, the default right now is 2 - because it takes 2 consecutive mustache braces for the parser to determine that we have a mustache construct, i.e. {{....}}.

Developers should have the ability to set this value to 1 for instance - if they are generating markup for frameworks like AMP and others in which 2 consecutive mustache braces i.e. {{...}} already have special meaning

@tonyobanon tonyobanon changed the title Add parserOption to allow developers define what mustache construct looks like Add parserOption to allow developers define what a mustache construct looks like Mar 8, 2023
@jaylinski
Copy link
Member

I think this would be hard to implement, since the parser is generated from this spec:

<emu>[^\x00]{2,}?/("{{"|"\\{{"|"\\\\{{"|<<EOF>>) {

The spec is compiled to JS and shipped via npm. I think in order to allow different mustache-syntax, the generated parser would have to be able to set different syntax dynamically, and I think https://github.com/zaach/jison can't do this.

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

No branches or pull requests

2 participants