3 <title>CodeMirror: Smarty mode
</title>
4 <meta charset=
"utf-8"/>
5 <link rel=stylesheet
href=
"../../doc/docs.css">
7 <link rel=
"stylesheet" href=
"../../lib/codemirror.css">
8 <script src=
"../../lib/codemirror.js"></script>
9 <script src=
"smarty.js"></script>
10 <style type=
"text/css">.CodeMirror {border-top:
1px solid black; border-bottom:
1px solid black;}
</style>
12 <a href=
"http://codemirror.net"><img id=logo
src=
"../../doc/logo.png"></a>
15 <li><a href=
"../../index.html">Home
</a>
16 <li><a href=
"../../doc/manual.html">Manual
</a>
17 <li><a href=
"https://github.com/marijnh/codemirror">Code
</a>
20 <li><a href=
"../index.html">Language modes
</a>
21 <li><a class=active
href=
"#">Smarty
</a>
27 <form><textarea id=
"code" name=
"code">
28 {extends
file=
"parent.tpl"}
29 {include
file=
"template.tpl"}
31 {* some example Smarty content *}
32 {if isset($name) && $name == 'Blog'}
34 {$integer =
451}, {$array[] =
"a"}, {$stringvar =
"string"}
35 {assign var='bob' value=$var.prop}
36 {elseif $name == $foo}
37 {function name=menu level=
0}
38 {foreach $data as $entry}
41 {menu data=$entry level=$level+
1}
47 {/if}
</textarea></form>
50 var editor = CodeMirror.fromTextArea(document.getElementById(
"code"), {
58 <h3>Smarty
2, custom delimiters
</h3>
59 <form><textarea id=
"code2" name=
"code2">
60 {--extends
file=
"parent.tpl"--}
61 {--include
file=
"template.tpl"--}
63 {--* some example Smarty content *--}
64 {--if isset($name) && $name == 'Blog'--}
66 {--$integer =
451--}, {--$array[] =
"a"--}, {--$stringvar =
"string"--}
67 {--assign var='bob' value=$var.prop--}
68 {--elseif $name == $foo--}
69 {--function name=menu level=
0--}
70 {--foreach $data as $entry--}
71 {--if is_array($entry)--}
73 {--menu data=$entry level=$level+
1--}
79 {--/if--}
</textarea></form>
82 var editor = CodeMirror.fromTextArea(document.getElementById(
"code2"), {
96 <textarea id=
"code3" name=
"code3">
97 Nested tags {$foo={counter one=
1 two={inception}}+
3} are now valid in Smarty
3.
101 console.log(
"Smarty 3 permits single curly braces followed by whitespace to NOT slip into Smarty mode.");
105 {assign var=foo value=[
1,
2,
3]}
106 {assign var=foo value=['y'=
>'yellow','b'=
>'blue']}
107 {assign var=foo value=[
1,[
9,
8],
3]}
109 {$foo=$bar+
2} {* a comment *}
110 {$foo.bar=
1} {* another comment *}
111 {$foo = myfunct(($x+$y)*
3)}
112 {$foo = strlen($bar)}
113 {$foo.bar.baz=
1}, {$foo[]=
1}
115 Smarty
"dot" syntax (note: embedded {} are used to address ambiguities):
117 {$foo.a.b.c} =
> $foo['a']['b']['c']
118 {$foo.a.$b.c} =
> $foo['a'][$b]['c']
119 {$foo.a.{$b+
4}.c} =
> $foo['a'][$b+
4]['c']
120 {$foo.a.{$b.c}} =
> $foo['a'][$b['c']]
122 {$object-
>method1($x)-
>method2($y)}
</textarea>
125 var editor = CodeMirror.fromTextArea(document.getElementById(
"code3"), {
133 <p>A plain text/Smarty version
2 or
3 mode, which allows for custom delimiter tags.
</p>
135 <p><strong>MIME types defined:
</strong> <code>text/x-smarty
</code></p>