larryhudson / personal-site-11ty

0 stars 2 forks source link

Escaping code #3

Open robdodson opened 3 years ago

robdodson commented 3 years ago

Hi I happened across your blog post https://www.larryhudson.io/blog/2020/02/escaping-nunjucks-in-eleventy/

I wanted to mention that if you want to escape nunjucks in a code fence you can use the {% raw %} and {% endraw %} built-in nunjucks tag.

Here's how we do it on developer.chrome.com https://github.com/GoogleChrome/developer.chrome.com/blame/990669af269a02c846ae0bd0d1ef84b7f31f72a7/site/en/docs/handbook/components/index.md#L17-L21

Also note that if you need to show a code fence inside of another code fence you can give the outer code fence four backticks instead of three https://github.com/GoogleChrome/developer.chrome.com/blame/990669af269a02c846ae0bd0d1ef84b7f31f72a7/site/en/docs/handbook/components/index.md#L29-L43

larryhudson commented 3 years ago

Thank you very much Rob! I've taken in the change and updated the instructions for anyone else that stumbles upon the post.