Chapter 3. Basic Syntax

Table of Contents
Comments
Variables
Functions
Attributes
Embedding Vars in Double Quotes
Math
Escaping Smarty Parsing

All Smarty template tags are enclosed within delimiters. By default, these delimiters are { and }, but they can be changed.

所有的 Smarty 樣板標籤都是被阻斷符號(delimiter)所包圍起來的,預設符號是 {},不過是可以變更的。

For these examples, we will assume that you are using the default delimiters. In Smarty, all content outside of delimiters is displayed as static content, or unchanged. When Smarty encounters template tags, it attempts to interpret them, and displays the appropriate output in their place.

在接下來的範例中,我們假設你是使用的預設符號。在 Smarty 中,在阻斷符號以外的 內容都被視為靜態內容,是不會改變的,在遇到樣版標籤後,Smarty 會試著解譯所遇到的標籤 ,且試著呈現合宜的輸出內容。

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. They are used for making internal notes in the templates.

樣版註解是被星號所包圍的,且由阻斷符號所包圍著的,如:{* this is a comment *} 。Smarty 的注釋是不會顯示在最後的輸出中的,注釋只被用來在樣版中作內部備註的而已。

Example 3-1. 註解

{* Smarty *}

{* include the header file here *}
{include file="header.tpl"}

{include file=$includeFile}

{include file=#includeFile#}

{* display dropdown lists *}
<select name="company">
{html_options values=$vals selected=$selected output=$output}
</select>