Replies: 2 comments
-
It might be possible in Node.js, but the parser is compiled during the build process and even in Node, the compiled version is used as entry-point. So if you wanted to do that, you'd have compile the parser during runtime, which would make "jison" a normal dependency rather than a dev-dependency. Of course, you could write your own parser and pass the generated AST into the One (long term) plan of mine is to extract the parser into its own module (I started here), but I have generally very little time to work on that. @wycats has also started a project to rewrite the parser (see https://github.com/wycats/hbs-parser-next) with a different approach. |
Beta Was this translation helpful? Give feedback.
-
@nknapp Hi Nils! That's some good info. I didn't realize that the parser was being compiled at build time, but that makes sense now. The idea of putting the parser in its own module seems like a good approach. I think it beats the idea of compiling it on-the-fly, both from a code size and performance standpoint. I wasn't able to quickly understand the approach @wycats is taking, but I'd love to learn about it, too. Also, let me know if/how I can help. |
Beta Was this translation helpful? Give feedback.
-
Before filing issues, please check the following points first:
This will probably help you to get a solution faster.
For bugs, it would be great to have a PR with a failing test-case.
Yes, I have read all the issues and other discussion I could find on the idea of custom delimiters and why it's not supported. I know there is at least one "hack" that essentially monkey-patches handlebars and of course there is the option of doing a string replacement of your template. Probably the most reasonable answer is to fork the library and modify
handlebars.l
. But of course that has the significant downside of having an orphan library that doesn't benefit from any future development.So it got me thinking: If everything about the delimiters that handlebars uses is indeed contained within
handlebars.l
, it should be possible to come up with alternative versions of that file that use different delimiters. That's essentially the approach you'd be taking if you forked the library. But I'm wondering if there might be a way to "select" one from a list ofhandlebars.l
files when the library is instantiated, so that multiple versions of it could be supported. It seems like that would minimize any potential problems with the existing parser, since it wouldn't be touched. The additional versions ofhandlebars.l
could be developed as separate projects or incorporated here, but their use would be completely optional and would have no effect on the existing code-base.Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions