Debian Codegraph @

examples/prism-smarty.html

raw symbols SCIP
1 <h2>Comments</h2>
2 <pre><code>{* This is a comment with &lt;p>some markup&lt;/p> in it *}
3 {* Multi-line
4 comment *}</code></pre>
5
6 <h2>Variables</h2>
7 <pre><code>{$foo}
8 {$foo.bar}
9 {$foo.$bar}
10 {$foo[$bar]}
11 {$foo->bar}
12 {$foo->bar()}
13 {#foo#}
14 {$smarty.config.foo}
15 {$foo[bar]}
16 </code></pre>
17
18 <h2>Strings and numbers</h2>
19 <pre><code>{$foo[4]}
20 {$foo['bar']}</code></pre>
21
22 <h2>Tags and filters</h2>
23 <pre><code>{assign var=foo value='baa'}
24 {include file='header.tpl'}
25 {$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}
26 {$title|truncate:40:'...'}
27 {$myArray|@count}
28
29 {math equation="height * width / division"
30 height=$row_height
31 width=$row_width
32 division=#col_div#}</code></pre>
33
34 <h2>Control flow</h2>
35
36 <pre><code>{if ( $amount &lt; 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
37 ...
38 {/if}
39 {if count($var) gt 0}{/if}
40 {if $var is even by 3}
41 ...
42 {/if}
43
44 {foreach from=$myArray item=i name=foo}
45 {$smarty.foreach.foo.index}|{$smarty.foreach.foo.iteration},
46 {/foreach}
47
48 &lt;ul>
49 {foreach from=$items key=myId item=i}
50 &lt;li>&lt;a href="item.php?id={$myId}">{$i.no}: {$i.label}&lt;/li>
51 {/foreach}
52 &lt;/ul>
53 </code></pre>
54
55 <h2>Literal section</h2>
56 <pre><code>{literal}
57 &lt;script>
58 (function() { /* This is JS, not Smarty */ } ());
59 &lt;/script>
60 {/literal}
61
62 &lt;style type="text/css">
63 {literal}
64 /* this is an intersting idea for this section */
65 .madIdea{
66 border: 3px outset #ffffff;
67 margin: 2 3 4 5px;
68 background-color: #001122;
69 }
70 {/literal}
71 &lt;/style></code></pre>