Closed floatrx closed 6 years ago
Can't find anything related to with
in nunjucks templating docs. Are you sure this syntax is present?
The {% with %}
tag doesn't exist. To pass a variable to an include, you can either do this:
<!-- index.html -->
{% set name = "Charles Dickens" %}
{% set year = 1812 %}
{% include "author.html" %}
<!-- author.html -->
<h1>{{ name }}</h1>
<p>{{ name }} was born in {{ year }}.</p>
Or use a macro, like this:
<!-- index.html -->
{% from "author.html" import author %}
{{ author("Charles Dickens", 1812) }}
<!-- author.html -->
{% macro author(name, year) %}
<h1>{{ name }}</h1>
<p>{{ name }} was born in {{ year }}.</p>
{% endmacro %}
Both will render:
<!-- index.html -->
<h1>Charles Dickens</h1>
<p>Charles Dickens was born in 1812.</p>
When i trying to use {% with %} i received an error message on build...