Skip to content

7.2 Appendix B Comparison of syntax of Smarty and Div

rafageist edited this page Jul 16, 2025 · 1 revision

Loops

Smarty:

{foreach $foo as $bar}
	  <a href="{$bar.zig}">{$bar.zag}</a>
	  <a href="{$bar.zig2}">{$bar.zag2}</a>
	  <a href="{$bar.zig3}">{$bar.zag3}</a>
	{foreachelse}
	  There were no rows found
{/foreach}

Div:

[$foo]
  <a href="{$zig}">{$zag}</a>
  <a href="{$zig2}">{$zag2}</a>
  <a href="{$zig3}">{$zag3}</a>
@empty@
  There were no rows found
[/$foo]

Include

Smarty:

{include file="header.tpl"}

Div:

(% header %}

Iterations

Smarty:

{for $x = 1 to 20 step 2}
	  {$x}
{/for}

Div:

[:1,20,x,2:]
	  {$x} 
[/]
Clone this wiki locally