Constant Vallee

Escape Nunjucks in Markdown

Writing my last post I had a problem. How do you include code with Nunjucks template in your markdown when Nunjucks is your templating language?

Well you wrap your code with

{% raw %}
Code goes here
{% endraw %}

I actually had to use another technique to be able to explain this 🤯. Thanks to Larry Hudson for this one.

{{ "{% raw %}" | escape}}

From the docs the tag verbatim is supposed to do the same but I get an error with "tag verbatim not found" if I wrap any blocks

{% verbatim %}{% endverbatim %}