因为似乎swig模板is not able to do some basic stuff,例如在if
语句中括号内有两个条件,我想知道你们如何处理这个问题而不必重复代码:
{% if( absence.approved and absence.rejected) or (demo.demo and demo.test) %}
whatever
{% endif %}
现在因为Swig doesn't support it ...
而打破了视图答案 0 :(得分:1)
删除括号,它应该可以正常工作
{% if absence.approved and absence.rejected or demo.demo and demo.test %}
whatever
{% endif %}
答案 1 :(得分:-1)
如果你修正了第一个括号的位置,则工作正常:
> var swig = require('swig')
> swig.render('{% if( foo and bar) or (baz and bop) %}yep{% endif %}');
Error: Unexpected tag "if( foo and bar) or (baz and bop)" on line 1.
> swig.render('{% if (foo and bar) or (baz and bop) %}yep{% endif %}');
''
>