Search code examples
javascripthtmlnunjucks

Template render error


I'm using nunjucks to render some variables:

    <div class="zoomable zoomable-{{ slide.index }}"> << this works

        {% if slide.temp is none %} << this doesn't
            {% include "layouts/"+{{slide.layout}} %} << this doesn't
        {% endif %}

    </div>

When the JS calls nunjucks.render, I get the following error:

parseAggregate: expected colon after dict key on the include

There are two issues with this:

  • It's not supposed to skip the condition, because the property temp doesn't exist.
  • Is it not letting me access the slide properties? Because slide.layout is valid

Am I doing something wrong?


Solution

  • I think you just need to remove the curly brackets i.e.

    {% include "layouts/" + slide.layout %}