9e41733807f99b0a91424dc616fe518d5b76d86d
[myslice.git] / third-party / codemirror-3.15 / mode / smarty / index.html
1 <!doctype html>
2 <html>
3   <head>
4     <meta charset="utf-8">
5     <title>CodeMirror: Smarty mode</title>
6     <link rel="stylesheet" href="../../lib/codemirror.css">
7     <script src="../../lib/codemirror.js"></script>
8     <script src="smarty.js"></script>
9     <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10     <link rel="stylesheet" href="../../doc/docs.css">
11   </head>
12   <body>
13     <h1>CodeMirror: Smarty mode</h1>
14
15         <h3>Default settings (Smarty 2, <b>{</b> and <b>}</b> delimiters)</h3>
16     <form><textarea id="code" name="code">
17 {extends file="parent.tpl"}
18 {include file="template.tpl"}
19
20 {* some example Smarty content *}
21 {if isset($name) && $name == 'Blog'}
22   This is a {$var}.
23   {$integer = 451}, {$array[] = "a"}, {$stringvar = "string"}
24   {assign var='bob' value=$var.prop}
25 {elseif $name == $foo}
26   {function name=menu level=0}
27     {foreach $data as $entry}
28       {if is_array($entry)}
29         - {$entry@key}
30         {menu data=$entry level=$level+1}
31       {else}
32         {$entry}
33       {/if}
34     {/foreach}
35   {/function}
36 {/if}</textarea></form>
37
38     <script>
39       var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
40         lineNumbers: true,
41         mode: "smarty"
42       });
43     </script>
44
45     <br />
46
47         <h3>Smarty 2, custom delimiters</h3>
48     <form><textarea id="code2" name="code2">
49 {--extends file="parent.tpl"--}
50 {--include file="template.tpl"--}
51
52 {--* some example Smarty content *--}
53 {--if isset($name) && $name == 'Blog'--}
54   This is a {--$var--}.
55   {--$integer = 451--}, {--$array[] = "a"--}, {--$stringvar = "string"--}
56   {--assign var='bob' value=$var.prop--}
57 {--elseif $name == $foo--}
58   {--function name=menu level=0--}
59     {--foreach $data as $entry--}
60       {--if is_array($entry)--}
61         - {--$entry@key--}
62         {--menu data=$entry level=$level+1--}
63       {--else--}
64         {--$entry--}
65       {--/if--}
66     {--/foreach--}
67   {--/function--}
68 {--/if--}</textarea></form>
69
70     <script>
71       var editor = CodeMirror.fromTextArea(document.getElementById("code2"), {
72         lineNumbers: true,
73         mode: {
74           name: "smarty",
75           leftDelimiter: "{--",
76           rightDelimiter: "--}"
77         }
78       });
79     </script>
80
81         <br />
82
83         <h3>Smarty 3</h3>
84
85         <textarea id="code3" name="code3">
86 Nested tags {$foo={counter one=1 two={inception}}+3} are now valid in Smarty 3.
87
88 <script>
89 function test() {
90         console.log("Smarty 3 permits single curly braces followed by whitespace to NOT slip into Smarty mode.");
91 }
92 </script>
93
94 {assign var=foo value=[1,2,3]}
95 {assign var=foo value=['y'=>'yellow','b'=>'blue']}
96 {assign var=foo value=[1,[9,8],3]}
97
98 {$foo=$bar+2} {* a comment *}
99 {$foo.bar=1}  {* another comment *}
100 {$foo = myfunct(($x+$y)*3)}
101 {$foo = strlen($bar)}
102 {$foo.bar.baz=1}, {$foo[]=1}
103
104 Smarty "dot" syntax (note: embedded {} are used to address ambiguities):
105
106 {$foo.a.b.c}      => $foo['a']['b']['c']
107 {$foo.a.$b.c}     => $foo['a'][$b]['c']
108 {$foo.a.{$b+4}.c} => $foo['a'][$b+4]['c']
109 {$foo.a.{$b.c}}   => $foo['a'][$b['c']]
110
111 {$object->method1($x)->method2($y)}</textarea>
112
113         <script>
114                 var editor = CodeMirror.fromTextArea(document.getElementById("code3"), {
115                         lineNumbers: true,
116                         mode: "smarty",
117                         smartyVersion: 3
118                 });
119         </script>
120
121
122     <p>A plain text/Smarty version 2 or 3 mode, which allows for custom delimiter tags.</p>
123
124     <p><strong>MIME types defined:</strong> <code>text/x-smarty</code></p>
125   </body>
126 </html>