Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

Chapter 3. 基本语法

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>

  

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 20 plus 5? (Are you human?)

Advertisement