Eleventy: Error with nunjucks syntax in triple backticks

Created on 4 Dec 2018  路  7Comments  路  Source: 11ty/eleventy

I have an article that talked about using Nunjucks. I have code examples fenced with triple backticks. Here's an example:

screenshot 2018-12-05 at 2 33 07 am

But they error out:

screenshot 2018-12-05 at 2 35 27 am

What can I do about this? Totally clueless here.

education

Most helpful comment

This works with Liquid. Gotta look if Nunjucks has something like that. (edit: it has the same). Put this inside the triple backtick blocks:

{%- raw -%}

{% extends "layout.nunjucks" %}

{%- endraw -%}

All 7 comments

This works with Liquid. Gotta look if Nunjucks has something like that. (edit: it has the same). Put this inside the triple backtick blocks:

{%- raw -%}

{% extends "layout.nunjucks" %}

{%- endraw -%}

Yes! @kleinfreund is correct there!

The other thing you can do if you want is to disable template pre-processing of markdown files altogether (they would only transform markdown)
https://www.11ty.io/docs/languages/#overriding-the-template-language

For a single file:

templateEngineOverride: md
---

Or using the markdownTemplateEngine: false global config option: https://www.11ty.io/docs/config/#default-template-engine-for-markdown-files

More about Nunjucks raw or Liquid raw.

This is an automated message to let you know that a helpful response was posted to your issue and for the health of the repository issue tracker the issue will be closed. This is to help alleviate issues hanging open waiting for a response from the original poster.

If the response works to solve your problem鈥攇reat! But if you鈥檙e still having problems, do not let the issue鈥檚 closing deter you if you have additional questions! Post another comment and I will reopen the issue. Thanks!

ok cool! Thanks!

For a single file:

templateEngineOverride: md
---

@zachleat Using above suggestion, the file then stops getting generated in the final build. Not sure if that is a bug or something intentional.

@chinchang I'd recommend filing a separate issue but I'm guessing md isn't one of your listed template formats? https://www.11ty.io/docs/config/#template-formats

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michrome picture michrome  路  3Comments

nebrelbug picture nebrelbug  路  3Comments

zachleat picture zachleat  路  3Comments

jamrelian picture jamrelian  路  3Comments

DirtyF picture DirtyF  路  3Comments