EZ Publish/EZ Publish 模板注释
来自站长百科
|
EZ Publish | EZ Publish安装与卸载 | EZ Publish的使用 | EZ Publish常见问题 | EZ Publish其他 |
模板语言[ ]
eZ Publish 模板语言允许从系统内部提取信息并可用来解决通用的程序问题如:条件分支,循环等。所有eZ Publish 特有的代码都需要被放置在一对大括号"{"和"}"内部。eZ Publish 模板是HTML 与eZ Publish模板代码的组合。所有在大括号内部的代码都会被eZ Publish 解析。大括号外部的内容会被eZ Publish忽略,因而会被直接发送给浏览器。
大括号问题
因为大括号是eZ Publish 的保留符号,它被用来定义代码块,这些符号不能在代码中直接使用。例如:Javascript 代码不能被直接嵌入代码因为Javascript 会用到大括号。所有非模板特有的代码/文本必须为放置在"literal"标签内部。"literal"标签内的内容会被eZ Publish 模板解释器忽略。下例演示了literal 标签的用法:
...
{literal}
<script language="JavaScript" type="text/javascript">
<!--
window.onload=function()
{
document.getElementById( 'sectionName' ).select();
document.getElementById( 'sectionName' ).focus();
}
-->
</script>
{/literal}
...
输出大括号
可以用两个模板函数:"ldelim"和"rdelim"(left delimiter 和right delimiter 的缩写)来输出大括号。下例演示了这些函数的用法:
...
This is the left curly bracket: {ldelim}
This is the right curly bracket: {rdelim}
...
输出:
This is the left curly bracket: {
This is the right curly bracket: }
模板注释[ ]
eZ Publish 模板的注释由"{*"和"*}"封装。注释标签不能嵌套。
单行注释
{*
This is a single line comment.
*}
多行注释
{*
This is a long comment that
spans across several lines
within the template file.
*}
嵌套注释(非法)
{*
{*
Nested comments are not supported!
*}
This text will be displayed.
*}
输出:
This text will be displayed.