最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Template render error - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question edited Apr 14, 2017 at 14:38 amigo21 asked Feb 27, 2017 at 16:54 amigo21amigo21 3912 gold badges6 silver badges18 bronze badges 1
  • Also not sure if none is a valid parison, haven't used nunjucks before. Maybe try if not slide.temp – theleebriggs Commented Feb 27, 2017 at 17:30
Add a ment  | 

1 Answer 1

Reset to default 10

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

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

发布评论

评论列表(0)

  1. 暂无评论