<table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><th colspan="3" align="center">Smarty - the compiling PHP template engine</th></tr><tr><td width="25%" align="left" valign="bottom"><a href="language.basic.syntax.html" accesskey="P">Prev</a></td> <td width="50%" align="center" valign="bottom">Chapter 3. Basic Syntax[第3章.基本语法]</td> <td width="25%" align="right" valign="bottom"><a href="language.syntax.variables.html" accesskey="N">Next</a></td></tr></table> # Comments[注释] Template comments are surrounded by asterisks, and that is surrounded by the delimiter tags like so:{* this is a comment *} Smarty comments are NOT displayed in the final output of the template, unlike <!-- HTML comments-->. These are useful for making internal notes in the templates which no one will see ;-) 模板注释被*星号包围,而两边的星号又被定界符包围,例如 {* this is a comment *} 。 smarty注释不会在模板文件的最后输出中出现,这与<!-- HTML 注释-->不同(译注:html注释在页面源码中可见,而smarty注释则不能)。这点非常有用,试想,注释只存在于模板里面,而在输出的页面中谁也看不见:)。 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"><a name="AEN162"/><strong>Example 3.1. Comments within a template</strong><br/><b>例 3-1.模板注释</b><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td> <p> {* I am a Smarty comment, I don't exist in the compiled output *}<br/> &lt;html&gt;<br/> &lt;head&gt;<br/> &lt;title&gt;{$title}&lt;/title&gt;<br/> &lt;/head&gt;<br/> &lt;body&gt;<br/> {* another single line smarty comment *}<br/> &lt;!-- HTML comment that is sent to the browser --&gt;<br/> {* this multiline smarty<br/> comment is<br/> not sent to browser<br/> *}<br/> {*********************************************************<br/> Multi line comment block with credits block<br/> @ author: bg@example.com<br/> @ maintainer: support@example.com<br/> @ para: var that sets block style<br/> @ css: the style output<br/> **********************************************************}<br/> {* The header file with the main logo and stuff *}<br/> {include file='header.tpl'}</p> <p>{* Dev note: the $includeFile var is assigned in foo.php script *}<br/> &lt;!-- Displays main content block --&gt;<br/> {include file=$includeFile}<br/> {* this &lt;select&gt; block is redundant *}<br/> {*<br/> &lt;select name="company"&gt;<br/> {html_options options=$vals selected=$selected_id}<br/> &lt;/select&gt;<br/> *}<br/> &lt;!-- Show header from affiliate is disabled --&gt;<br/> {* $affiliate|upper *}<br/> {* you cannot nest comments *}<br/> {*<br/> &lt;select name="company"&gt;<br/> {* &lt;option value="0"&gt;-- none -- &lt;/option&gt; *}<br/> {html_options options=$vals selected=$selected_id}<br/> &lt;/select&gt;<br/> *}<br/> &lt;/body&gt;<br/> &lt;/html&gt;</p> </td></tr></table></div></td></tr></table> <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="language.basic.syntax.html" accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="language.syntax.variables.html" accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Smarty For Template Designers<br/> 模板设计者篇 </td> <td width="34%" align="center" valign="top"><a href="smarty.for.designers.html" accesskey="U">Up</a></td> <td width="33%" align="right" valign="top">Variables<br/> 变量</td> </tr></table>