Get Smarty

Donate

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 glasses from Cheapglasses123.com and save up to 80%.

Where to buy prescription glasses? EyewearCanada.com is your best choice!

Advertisement

{literal}

{literal}可以让一个模板区域的字符原样输出。 这经常用于保护页面上的Javascript或css样式表,避免因为Smarty的定界符{语法}而错被解析。 在{literal}{/literal}内的任何标签都不会被解析,原样输出。 所以如果你有需要放到{literal}内的标签,首先可以考虑是否用 {ldelim}{rdelim} 来代替定界符在页面上的显示(不用{literal})。

Note

因为Smarty会忽略那些带空格的定界符,所以通常不需要使用{literal}{/literal},。 请确定你的Javascript或者CSS样式表的大括号周围是有空格的。这是Smarty 3的新特性。

Example 7.59. {literal} 标签


<script>
   // the following braces are ignored by Smarty
   // since they are surrounded by whitespace
   function myFoo {
     alert('Foo!');
   }
   // this one will need literal escapement
   {literal}
     function myBar {alert('Bar!');}
   {/literal}
</script>

  

参见 {ldelim} {rdelim}避免Smarty解析

Comments
No comments for this page.

Advertisement