Basic Syntax

Chapter 3. Basic Syntax

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

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.

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

Example 3-1. Comments

<body>
{* a single line comment *}

{* this multiline
    comment is
   not sent to browser
*}

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


{* Dev note:  $includeFile is assigned in foo.php script  *}
<!-- this html comment is sent to browser -->
{include file=$includeFile}

{include file=#includeFile#}

{* this <select> block is redundant *}
{*
<select name="company">
  {html_options options=$vals selected=$selected_id}
</select>
*}
</body>
© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.