我一直在浏览几个Catalyst教程,他们都倾向于使用Template Toolkit而不是HTML :: Template.
我花了很多时间使用HTML :: Template而且我喜欢它,虽然我可以看到TT的强大功能,但我不知道它,我觉得我会一次学习两件事; 另外,因为它在模板中进行处理,我不确定我的HTML :: Template $template->param(foo => \$bar);代码会在哪里发生!
有人知道使用HTML :: Template的好教程/代码示例吗?
我在Perl的HTML :: Template模块上学习本教程.这是模板:
<!--template2.tmpl-->
<html>
<body>
<table>
<tr>
<th>Language</th>
<th>Description</th>
</tr>
<tmpl_loop name="language">
<tr>
<td><tmpl_var name="language_name"></td>
<td><tmpl_var name="description"></td>
</tr>
</tmpl_loop>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是CGI测试程序:
#!"C:\Strawberry\perl\bin\perl.exe" -wT
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);
use HTML::Template;
my @rows = (
{
language_name => 'C#',
description => 'Created by Microsoft'
},
{
language_name => 'PHP',
description => 'Hypertext Preprocessor'
},
{
language_name => 'Haskell',
description => 'Functional language'
},
);
print header;
my $template=HTML::Template->new(filename=>'template2.tmpl');
$template->param(language => @rows);
print $template->output();
Run Code Online (Sandbox Code Playgroud)
此操作失败,并显示以下错误: HTML::Template::param() …