ami*_*o21 2 html javascript nunjucks
我正在使用 nunjucks 来呈现一些变量:
<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>
Run Code Online (Sandbox Code Playgroud)
当 JS 调用 nunjucks.render 时,出现以下错误:
parseAggregate: expected colon after dict key 在 include
这有两个问题:
temp
不存在。slide属性?因为
slide.layout有效难道我做错了什么?
我认为你只需要删除curly bracketsie
{% include "layouts/" + slide.layout %}