Get Smarty

Donate

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

Advertisement

{literal}

Tag {literal} membolehkan blok data diambil secara literal. Ini biasanya dipakai sekitar blok Javascript atau stylesheet di mana {kurung kurawal} akan berpengaruh dengan sintaks pembatas template. Apapun di dalam tag {literal}{/literal} tidak diinterpretasikan, but displayed as-is. If you need template tags embedded in a {literal} block, consider using {ldelim}{rdelim} to escape the individual delimiters instead.

Teladan 7-25. {literal} tags

{literal}
<script type="text/javascript">
<!--
  function isblank(field) {
    if (field.value == '')
      { return false; }
    else
      {
      document.loginform.submit();
      return true;
    }
  }
// -->
</script>
{/literal}

Teladan 7-26. Javascript function example

<script language="JavaScript" type="text/javascript">
{literal}
function myJsFunction(name, ip){
   alert("The server name\n" + name + "\n" + ip);
}
{/literal}
</script>
<a href="javascript:myJsFunction('{$smarty.server.SERVER_NAME}','{$smarty.server.SERVER_ADDR}')">Click here for the Server Info</a>

Teladan 7-27. Some css style in a template

{* included this style .. as an experiment *}
<style type="text/css">
{literal}
/* this is an intersting idea for this section */
.madIdea{
    border: 3px outset #ffffff;
    margin: 2 3 4 5px;
    background-color: #001122;
}
{/literal}
</style>
<div class="madIdea">With smarty you can embed CSS in the template</div>

See also {ldelim} {rdelim} and the escaping Smarty parsing page.

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors