Nunjucks: how to escape brackets

Created on 8 Mar 2015  路  4Comments  路  Source: mozilla/nunjucks

I'm using hexo.io 3.0.0 which uses nunjuck 1.1.0
How can you escape brackets inside code tags?

Eg:<pre><code class="html"><div>{{ presentation.get("title") }}</div></code></pre>

So that I don't get the following error:
Template render error: Error: Unable to callpresentation["get"], which is undefined or falsey at Object.callWrap (/../node_modules/hexo/node_modules/nunjucks/src/runtime.js:221:15)

Most helpful comment

You can use the raw tag and anything inside them will be rendered as they are. {% raw %}{{ anything here }{} {} {% endraw %}

All 4 comments

You can use the raw tag and anything inside them will be rendered as they are. {% raw %}{{ anything here }{} {} {% endraw %}

thanks @jlongster. I think it would be a good idea to treat <code> as a {% raw %} tag. What do you think?

@gaboesquivel nunjucks is unaware of the HTML, it only handles tags specific to nunjucks, ie {{ output_tags }}, {% logic_tags %} and {# comment #}. You can use it for other formats as well, not just HTML.

I see... thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rayalan picture rayalan  路  5Comments

kud picture kud  路  3Comments

sandiprb picture sandiprb  路  5Comments

kamlekar picture kamlekar  路  5Comments

mattbasta picture mattbasta  路  6Comments