2017-02-27 316 views
0

我使用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> 

当JS调用nunjucks.render,我得到以下错误:

parseAggregate: expected colon after dict keyinclude

有是这两个问题:

  • 它不应该跳过的条件,b因为该属性temp 不存在。
  • 是不是让我访问slide属性?因为 slide.layout有效

我做错了什么?

+0

也不知道'none'是一个有效的比较,没有使用nunjucks。也许尝试'如果不是slide.temp' – theleebriggs

回答

2

我想你只需要之前删除curly brackets

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

+0

因为它已经在nunjucks方法结构中了,所以它不需要使用括号来插入。 – theleebriggs

+0

是的,谢谢!现在工作 – amigo21