4
How do I resolve a conflict between Handlebars and Jinja, since the syntax of both are similar?
4
How do I resolve a conflict between Handlebars and Jinja, since the syntax of both are similar?
2
You can use the tag raw
who will disregard whatever is inside her block:
{% raw %}
{{ title }}
{% endraw %}
In that case, title
will not be computed by Jinja.
Another way, slightly dirtier, is to use a variable expression:
{{ '{{' }}title{{ '}}' }}
Take a look at documentation from Japan if you have any questions.
0
Well, I have a different option, and maybe it’s better. How about changing the outline of jinja2?
class CustomFlask(Flask):
jinja_options = Flask.jinja_options.copy()
jinja_options.update(dict(
block_start_string='<%',
block_end_string='%>',
variable_start_string='%%',
variable_end_string='%%',
comment_start_string='<#',
comment_end_string='#>',
))
app = CustomFlask(__name__)
Follow link for more details -> https://gist.github.com/lost-theory/3925738
Browser other questions tagged python handlebars.js jinja2
You are not signed in. Login or sign up in order to post.
I don’t think it’s a good idea to change the syntax of jinja2. Although this is possible, it impairs the reusability of the code. What if you want to transport a Flask template to Django? I believe your solution is good for small projects only.
– ppalacios