文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>perl template --Block

perl template --Block

时间:2008-06-30  来源:sohu2000000

BLOCK

The BLOCK...END construct can be used to define template component blocks which can be processed with the INCLUDE, PROCESS and WRAPPER directives.

[% BLOCK tabrow %]
<tr>
<td>[% name %]<td>
<td>[% email %]</td>
</tr>
[% END %]

<table>
[% PROCESS tabrow name='Fred' email='[email protected]' %]
[% PROCESS tabrow name='Alan' email='[email protected]' %]
</table>

A BLOCK definition can be used before it is defined, as long as the definition resides in the same file. The block definition itself does not generate any output.

[% PROCESS tmpblk %]

[% BLOCK tmpblk %] This is OK [% END %]

You can use an anonymous BLOCK to capture the output of a template fragment.

[% julius = BLOCK %]
And Caesar's spirit, ranging for revenge,
With Ate by his side come hot from hell,
Shall in these confines with a monarch's voice
Cry 'Havoc', and let slip the dogs of war;
That this foul deed shall smell above the earth
With carrion men, groaning for burial.
[% END %]

Like a named block, it can contain any other template directives which are processed when the block is defined. The output generated by the block is then assigned to the variable julius.

Anonymous BLOCKs can also be used to define block macros. The enclosing block is processed each time the macro is called.

[% MACRO locate BLOCK %]
The [% animal %] sat on the [% place %].
[% END %]

[% locate(animal='cat', place='mat') %] # The cat sat on the mat
[% locate(animal='dog', place='log') %] # The dog sat on the log
相关阅读 更多 +
排行榜 更多 +
别惹神枪手安卓版

别惹神枪手安卓版

冒险解谜 下载
坦克战争世界

坦克战争世界

模拟经营 下载
丛林反击战

丛林反击战

飞行射击 下载