-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Alternative delimiters or changing delimiters #227
Comments
This would, indeed, be nice (coming from another Django user). For now, here's a workaround that someone has developed: https://github.com/yavorskiy/django-handlebars |
Thanks for the tip ! |
Its better to precompile your templates into javascript functions and include them with your javascript assets, which removes this issue completely. |
I think we're pretty unlikely to be able to support custom delimiters since that's part of the lexer which isn't configurable. However, it may be possible to add an alternate syntax. I also recommend precompilation. |
Ok .. thanks for the tip. Precompilation sounds pretty good to me. However there's still some cases when you're not able to precompile and you'll have clashes between template languages ... alternate syntax would be a nice way out. |
Just another Django user that would find nice to choose between two syntaxes. Personally, I have the need to preprocess the templates server side so I have no chance of compiling them as an static asset. |
If you're rolling Django 1.5+ you can use the https://docs.djangoproject.com/en/1.5/ref/templates/builtins/#verbatim |
This isn't something that we are going to be able to support with our lexer setup. It sounds like there are some workarounds proposed by this group for the Django environment. |
I put this module together to make it easy to use custom delims if anyone is interested. suggestions for improvement or prs are welcome |
@jonschlinkert, great work. Do you have any idea how it can be easily injected to assemble in Grunt-initConfig? |
@korya, mind opening an issue on assemble to discuss? |
@wagenet @kpdecker so it's been two years and Handlebars is still the top templating tool for js. Is there willingness to even consider overcoming the limitations to making the delimiter configurable? I'm using Handlebars as a part of a Node library for static site generation, and precompiling doesn't apply if you're generating a static Angular app. It doesn't make sense to require users of the generator lib to use alternate tags throughout their entire Angular application for the sake of the templating language, when we know the templating will generally be quite minimal. I'm aware (and appreciative!) of @jonschlinkert's solution, but this really is a core concern. Thoughts? |
I am not sure about their plans. I believe the main argument against doing it remains the same: this requires changing the parser, which is generated and tested during build time. Our case was similar to yours one. We use handlebars to assemble our HTML templates during the project compilation (build time), and we use angular at runtime. First we started to escape the angular templates; that is in HTML file you write Since most of our effort is spent writing the angular apps, we decided to change the delimiters of handlebars rather than angular ones. We tried to reconfigure handlebars to use different delimiters at run-time. But we failed to integrate it into our setup. We use assemble.io to build the HTML templates, and there was always an edge case that did not work for us. Hence at some point we just decided to fork Handlebars and change its delimiters in the lexer itself. We decided to change the delimiters to I hope this can help you. |
@korya thanks for the detailed reply - using the module by Jon Schlinkert represents a similar option, and probably one we'll have to take. I brought it up her because the module that Jon wrote is a succinct script that just wraps handlebars and, unless there are caveats that I'm not aware of, it works. I'm hoping that the maintainers are at least open to this approach for now - simply allow users to specify alternate tags once, globally, but still have that configuration supported as a core feature. |
Hi !
I couldn't find if there is the possibility to change the delimiters for blocks or variables (
{{}}
,{{#
, ...).From a quick look in the source, the delimiters seem hard-coded in a regular expression, but I'd like to have the confirmation of that !?
Without giving complete freedom to chose the delimiters, it would be cool to be able to choose between alternative syntax.
My current problem is that I am using Django, and the delimiters of Django's templating langage and handlebar's clash. Therefore, where I need to use both template langages, I have to use very clumsy syntax like :
Thanks !
The text was updated successfully, but these errors were encountered: