关于HTML::Template中嵌套LOOP的问题
时间:2010-08-27
来源:互联网
最近在使用HTML::Template模块,觉得挺好用的,但是遇到了一个问题。
在嵌套的循环中,
for{
for{
@loop1;
}
@loop2;
}
在接下来向模板传值的时候遇到问题了。
我写做 $template->param( LOOP_ONE => [\@loop1, LOOP_TWO => \@loop2]);
可是一直会报错,不知道哪位高手能赐教一下,谢谢
在嵌套的循环中,
for{
for{
@loop1;
}
@loop2;
}
在接下来向模板传值的时候遇到问题了。
我写做 $template->param( LOOP_ONE => [\@loop1, LOOP_TWO => \@loop2]);
可是一直会报错,不知道哪位高手能赐教一下,谢谢
作者: Wayne_sama 发布时间: 2010-08-27
QUOTE:
for{
for{
@loop1;
}
@loop2;
}
for{
@loop1;
}
@loop2;
}
这是模板?
- $template->param( LOOP_ONE => [\@loop1, LOOP_TWO => \@loop2]);
作者: ynchnluiti 发布时间: 2010-08-27
QUOTE:
<TMPL_LOOP>s within <TMPL_LOOP>s are fine and work as you would expect. If the syntax for the "param()" call has you stumped, here's an example of a param call with one nested loop:
$template->param(LOOP => [
{ name => 'Bobby',
nicknames => [
{ name => 'the big bad wolf' },
{ name => 'He-Man' },
],
},
],
);
Basically, each <TMPL_LOOP> gets an array reference. Inside the array are any number of hash references. These hashes contain the name=>value pairs for a single pass over the loop template.
Inside a <TMPL_LOOP>, the only variables that are usable are the ones from the <TMPL_LOOP>. The variables in the outer blocks are not visible within a template loop. For the computer-science geeks among you, a <TMPL_LOOP> introduces a new scope much like a perl subroutine call. ...
$template->param(LOOP => [
{ name => 'Bobby',
nicknames => [
{ name => 'the big bad wolf' },
{ name => 'He-Man' },
],
},
],
);
Basically, each <TMPL_LOOP> gets an array reference. Inside the array are any number of hash references. These hashes contain the name=>value pairs for a single pass over the loop template.
Inside a <TMPL_LOOP>, the only variables that are usable are the ones from the <TMPL_LOOP>. The variables in the outer blocks are not visible within a template loop. For the computer-science geeks among you, a <TMPL_LOOP> introduces a new scope much like a perl subroutine call. ...
文档
作者: ynchnluiti 发布时间: 2010-08-27
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28