Smarty的标签都是使用定界符括起来。
默认定界符是{ 和
}, 但定界符可以被改变。
比如说在本手册,我们会假定你在使用默认的定界符。 在Smarty看来,任何在定界符之外的内容,都是静态的,或者是不改变的内容。 当Smarty读取到这些标签时,将会试图解析它们,并且在对应的位置输出结果。
模板中的注释是星号开头,然后外面包含着 定界符, 就像这样:
{* 这是一个注释 *}
Smarty的注释在不会在最终的页面输出里显示,
像<!-- HTML comments -->一样。
这是内部进行一些标记而不被人看到的好方法;-)
Example 3.1. 注释例子
{* 我是一个Smarty的注释, 显示输出时我不会存在 *}
<html>
<head>
<title>{$title}</title>
</head>
<body>
{* 另一个单行的注释例子 *}
<!-- HTML 注释会发送到浏览器 -->
{*
Smarty的多行
注释
不会发送到浏览器
*}
{*********************************************************
多行注释的说明栏
@ author: bg@example.com
@ maintainer: support@example.com
@ para: var that sets block style
@ css: the style output
**********************************************************}
{* 头部文件包括LOGO和其他东西 *}
{include file='header.tpl'}
{* 开发说明: $includeFile是通过foo.php赋值的 *}
<!-- 显示 main content 块 -->
{include file=$includeFile}
{* 这里的 <select> 块是多余的 *}
{*
<select name="company">
{html_options options=$vals selected=$selected_id}
</select>
*}
<!-- 变量被注释了 -->
{* $affiliate|upper *}
{* 注释不能嵌套 *}
{*
<select name="company">
{* <option value="0">-- none -- </option> *}
{html_options options=$vals selected=$selected_id}
</select>
*}
</body>
</html>
