[英]IF statement in Template Toolkit with Perl
I'm trying to set up a conditional in a.tt2 file using perl.我正在尝试使用 perl 在 a.tt2 文件中设置条件。 I have an object
page
that i need to check the title against.我有一个 object
page
,我需要检查标题。 however I can't seem to get it to work.但是我似乎无法让它工作。 where am I going wrong here?
我在哪里错了? I'm just trying to dump out the content at this stage to make sure its working but it just throws a
cannot render template
error message我只是想在这个阶段转储内容以确保其正常工作,但它只是抛出
cannot render template
错误消息
[% IF page.title eq 'User Api List' %]
[%
"<pre>";
USE dumper(indent = 1);
dumper.dump(page.title) | html
"</pre>";
%]
[% END %]
When I run that code it says:当我运行该代码时,它说:
file error - parse error - test.tt line 3: unexpected token (eq) [% IF page.title eq 'User Api List' %]%
Template Toolkit is not Perl.模板工具包不是 Perl。
The comparison operator for strings is ==
not eq
字符串的比较运算符是
==
而不是eq
You also forgot the ;
你也忘记了
;
after | html
之后
| html
| html
. | html
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.