summaryrefslogtreecommitdiff
path: root/docu/language_definition.html
blob: a21a86941408392fe644f96ab9d9d7ec1a784f7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en">
<head>
	<title>Language definition - STE Template Engine</title>
	<style type="text/css" media="screen">
		code, code pre {
			font-family: monospace;
			background: #eee;
		}
		* {
			font-family: sans-serif;
		}
		table {
			border-collapse: collapse;
		}
		table td, table th {
			border: thin solid #ccc;
			padding: 1mm;
			margin: 0mm;
		}
		table th {
			font-weight: bold;
			background: #eee;
		}
	</style>
	
</head>
<body>
	<h1>The <acronym>STE</acronym> Template Language</h1>
	<p>This is the documentation of the Template Language of the <strong>S</strong>TE <strong>T</strong>emplate <strong>E</strong>ngine.</p>
	
	<h2 id="toc">TOC</h2>
		<ol>
			<li>
				<a href="#basic_elems">Basic elements</a>
				<ol>
					<li><a href="#basic_elems_text">Text</a></li>
					<li><a href="#basic_elems_variable">Variable</a></li>
					<li><a href="#basic_elems_tag">Tag</a></li>
					<li>
						<a href="#basic_elems_tag">Pseudotag</a>
						<ol>
							<li><a href="#basic_elems_pseudotag_comment">ste:comment</a></li>
							<li><a href="#basic_elems_pseudotag_rawtext">ste:rawtext</a></li>
						</ol>
					</li>
				</ol>
			</li>
			<li><a href="#escaping">Escaping special chars</a></li>
			<li>
				<a href="#builtin">Builtin tags</a>
				<ol>
					<li><a href="#builtin_if">ste:if</a></li>
					<li><a href="#builtin_cmp">ste:cmp</a></li>
					<li><a href="#builtin_not">ste:not</a></li>
					<li><a href="#builtin_even">ste:even</a></li>
					<li><a href="#builtin_for">ste:for</a></li>
					<li><a href="#builtin_foreach">ste:foreach</a></li>
					<li><a href="#builtin_infloop">ste:infloop</a></li>
					<li><a href="#builtin_break">ste:break</a></li>
					<li><a href="#builtin_continue">ste:continue</a></li>
					<li><a href="#builtin_load">ste:load</a></li>
					<li><a href="#builtin_block">ste:block</a></li>
					<li><a href="#builtin_set">ste:set</a></li>
					<li><a href="#builtin_get">ste:get</a></li>
					<li><a href="#builtin_calc">ste:calc</a></li>
					<li><a href="#builtin_mktag">ste:mktag</a></li>
				</ol>
			</li>
			<li>
				<a href="#stdlib">Standard Library</a>
				<ol>
					<li><a href="#stdlib_escape">ste:escape</a></li>
					<li><a href="#stdlib_strlen">ste:strlen</a></li>
					<li><a href="#stdlib_arraylen">ste:arraylen</a></li>
					<li><a href="#stdlib_inc">ste:inc</a></li>
					<li><a href="#stdlib_dec">ste:dec</a></li>
					<li><a href="#stdlib_date">ste:date</a></li>
					<li><a href="#stdlib_in_array">ste:in_array</a></li>
					<li><a href="#stdlib_join">ste:join</a></li>
					<li><a href="#stdlib_split">ste:split</a></li>
					<li><a href="#stdlib_array_add">ste:array_add</a></li>
				</ol>
			</li>
		</ol>
	
	<h2 id="basic_elems">Basic Elements</h2>
		<p>The STE Template Language consists of four basic elements:</p>
	
		<h3 id="basic_elems_text">Text</h3>
			<p>Everything that is not a <a href="#basic_elems_variable">Variable</a>, a <a href="#basic_elems_tag">Tag</a> or a <a href="#basic_elems_pseudotag">Pseudotag</a> is Text.</p>
			<p>Also everything that is wrapped in the <a href="#basic_elems_pseudotag_rawtext">ste:rawtext</a> <a href="#basic_elems_pseudotag">pseudotag</a> will be Text, whereby all <a href="#basic_elems_tag">Tags</a> and <a href="#basic_elems_variable">Variables</a> will not be parsed.</p>
			<h4>Example:</h4>
			<p>
			<code><pre>&lt;ste:rawtext&gt;Foo &lt;ste:bar&gt;$baz[herpdederp]&lt;/ste:baz&gt;&lt;/ste:rawtext&gt;</pre></code>
			Will result in one text-element, but
			<code><pre>Foo &lt;ste:bar&gt;$baz[herpdederp]&lt;/ste:baz&gt;</pre></code>
			will result in one text-element and one tag-element containing one variable-element.
			</p>
	
		<h3 id="basic_elems_variable">Variable</h3>
			<p>Variables start with a <code>$</code> or can be wrapped within <code>${</code> and <code>}</code>, so you can write this: <code>${foo}ish</code></p>
			<p>Variable have names, these names can consist of letters (english alphabet; upper and lower case), numbers and underscores (<code>_</code>). As a regex: <code>[a-zA-Z0-9_]+</code></p>
			<p>A variable can also be an array. To access an array, wrap the desired fieldname within <code>[</code> and <code>]</code>. A fieldname can be constructed of <a href="#basic_elems_text">Text</a> and other Variables. So you can dynamically access fields: <code>$foo[$bar]</code>. These fieldnames can also be nested or concatenated: <code>$foo[$bar[baz]][herp][$de[derp]]</code></p>
			<p>If you want a literal <code>$</code> char, you can escape it: <code>\$</code></p>
			<p>Variables in STE are typeless, everything is text. In a boolean context, empty text usually represents false, else true.</p>
	
		<h3 id="basic_elems_tag">Tag</h3>
			<p>A Tag can be compared to a function. A Tag can have parameters and children <a href="#basic_elems">elements</a>.</p>
			<p>
				A Tag looks like a XML-Tag with the ste-Namespace.
				Just like their XML counterparts, they can wrap other elements (<code>&lt;ste:foo&gt;bar&lt;ste:baz&gt;herpdederp&lt;/ste:baz&gt;&lt;/ste:foo&gt;</code>) or can be self-closing (<code>&lt;ste:foo /&gt;</code>).
				And they can have additional parameters (or "attributes", using the XML terminology): <code>&lt;ste:foo bar="baz" /&gt;</code>
			</p>
			<p>A Tag is wrapped in <code>&lt;</code> and <code>&gt;</code>. The tag's name always start with <code>ste:</code> and can then consist of letters, numbers and underscores (Regex: <code>[a-zA-Z0-9_]+</code>).</p>
			<p>If the tag is self-closing, the last char is a <code>/</code> (e.g.: <code>&lt;ste:foo /&gt;</code>).</p>
			<p>If the tag is a closing one, the first char is a <code>/</code>. An opening Tag does not have a <code>/</code>.An example of an opening-closing Tag pair wrapping the text <code>bar</code>: <code>&lt;ste:foo&gt;bar&lt;/ste:foo&gt;</code></p>
			<p>
				Parameters of a tag consists of a name and the corresponding value (wrapped in <code>"</code> or <code>'</code>) separated by an <code>=</code> .<br />
				Parameters are separated by any whitespace (space, tab or newline) char.<br />
				Parameter values can consist of <a href="#basic_elems_text">Text</a> and <a href="#basic_elems_variable">Variable</a> elements <em>but not of Tags</em>!<br />
				If you need a literal <code>"</code> or <code>'</code> in a parameter value, you can escape them: <code>\"</code> or <code>\'</code> .<br />
				When using variables in parameter values, they will be "replaced" by their value. Because many tags need the variable and not its content, they expect only the variable's name. If you then write <code>foo="$bar"</code>, the tag will not operate on the <code>bar</code> variable but on the Variable with the name stored in <code>$bar</code>! So read the instructions to the tag carefully!
			</p>
			<p>Example: <code>&lt;ste:foo bar="baz" herp="literal quote sign: \""&gt;de &lt;ste:derp hehe="hoho$wtf[xd]" /&gt;&lt;/ste:foo&gt;</code></p>
	
		<h3 id="basic_elems_pseudotag">Pseudotag</h3>
			<p>Pseudotags look like normal tags, but they perform special tasks. There are currently two pseudotags:</p>
			<h4 id="basic_elems_pseudotag_comment">ste:comment</h4>
			<p>With the ste:comment pseudotag you can comment your template/code. Everything between <code>&lt;ste:comment&gt;</code> and <code>&lt;/ste:comment&gt;</code> will be ignored, before the real tokenization of the code starts.</p>
			<h4 id="basic_elems_pseudotag_rawtext">ste:rawtext</h4>
			<p>The ste:rawtext pseudotag will output a <a href="#basic_elems_text">Text</a> element with its wrapped content. It will prevent parsing of the content. Useful if you are embedding another script language, which uses the <code>$</code> char or also has a XML-Like syntax. No <a href="#escaping">escape sequences</a> will be translated! Can not be used in <a href="#basic_elems_tag">Tag</a> parameter values!</p>
	
	<h2 id="escaping">Escaping special chars</h2>
		<p>To get a literal <code>$</code>, <code>"</code> or other special chars, STE gives you the following escape sequences:</p>
		<table>
		<thead>
			<tr>
				<th>Escape Sequence</th>
				<th>Result</th>
				<th>Can be used in</th>
				<th>Notes</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>\$</td>
				<td>$</td>
				<td><a href="#basic_elems_text">Text elements</a></td>
				<td></td>
			</tr>
			<tr>
				<td>\"</td>
				<td>"</td>
				<td><a href="#basic_elems_tag">Tag</a> parameter values</td>
				<td></td>
			</tr>
			<tr>
				<td>\'</td>
				<td>'</td>
				<td><a href="#basic_elems_tag">Tag</a> parameter values</td>
				<td></td>
			</tr>
			<tr>
				<td>\?</td>
				<td>?</td>
				<td><a href="#basic_elems_text">Text elements</a></td>
				<td>More info: <a href="#builtin_if_short">short if-clause</a></td>
			</tr>
			<tr>
				<td>\~</td>
				<td>~</td>
				<td><a href="#basic_elems_text">Text elements</a></td>
				<td>More info: <a href="#builtin_if_short">short comparisons</a></td>
			</tr>
			<tr>
				<td>\{</td>
				<td>{</td>
				<td><a href="#basic_elems_text">Text elements</a></td>
				<td>More info: <a href="#builtin_if_short">short if-clause</a>, <a href="#builtin_if_short">short comparisons</a></td>
			</tr>
			<tr>
				<td>\}</td>
				<td>}</td>
				<td><a href="#basic_elems_text">Text elements</a></td>
				<td>More info: <a href="#builtin_if_short">short if-clause</a>, <a href="#builtin_if_short">short comparisons</a></td>
			</tr>
			<tr>
				<td>\|</td>
				<td>|</td>
				<td><a href="#basic_elems_text">Text elements</a></td>
				<td>More info: <a href="#builtin_if_short">short if-clause</a>, <a href="#builtin_if_short">short comparisons</a></td>
			</tr>
			<tr>
				<td>\\</td>
				<td>\</td>
				<td>Everywhere, where the other escape sequences are valid</td>
				<td></td>
			</tr>
		</tbody>
		</table>
		<p>Escape sequences are not translated in <a href="#basic_elems_pseudotag">Pseudotags</a></p>
	
	<h2 id="builtin">Builtin Tags</h2>
		<p><acronym>STE</acronym> has some builtin <a href="#basic_elems_tag">Tags</a>, that makes programming in STE possible.</p>
	
		<h3 id="builtin_if">ste:if</h3>
			<p>The ste:if Tag provides an if-clause to STE.</p>
			<p>ste:if can have the subtags ste:then and ste:else. Everything between <code>&lt;ste:if&gt;</code> and <code>&lt;/ste:if&gt;</code>, that is <strong>not</strong> an ste:then or ste:else tag, will be used as the condition.</p>
			<p>Every empty string (trailing whitespaces will be ignored) is considered as false, everything else is true.</p>
			<p>If the condition is true (i.e. not empty), the content of the ste:then block will be executed. Otherwise the ste:else tag (if present) will be executed.</p>
			<p>The ste:then Tag is mandatory, the ste:else tag is optional.</p>
			<p>
				Example:<br />
<code><pre>&lt;ste:if&gt;<br />	$foo<br />	&lt;ste:then&gt;Bar&lt;/ste:then&gt;<br />	&lt;ste:else&gt;Baz&lt;/ste:else&gt;<br />&lt;/ste:if&gt;</pre></code>
				If <code>$foo</code> is not empty, then <code>Bar</code> will be executed, otherwise <code>Baz</code>.
			</p>
			<h4 id="builtin_if_short">Short syntax for if-clause</h4>
				<p>Because if-clauses are used often, there is a short syntax:</p>
				<p><code>?{condition|then|else}</code></p>
				<p>This is equivalent to:</p>
				<p><code>&lt;ste:if&gt;condition&lt;ste:then&gt;then&lt;/ste:then&gt;&lt;ste:else&gt;else&lt;/ste:else&gt;&lt;/ste:if&gt;</code></p>
				<p><code>?</code>, <code>{</code>, <code>|</code> and <code>}</code> can be <a href="#escaping">escaped</a></p>
				<p>In this variant, the else part <strong>is not optional</strong>!</p>
		
		<h3 id="builtin_cmp">ste:cmp</h3>
			<p>With the ste:cmp tag you can compare two values.</p>
			<p>ste:cmp is selfclosing, the compared values are passed by parameters.</p>
			<p>It compares two values, a and b using an operator.</p>
			<p>
				a and b can be passed in two ways:
				<ul>
					<li>With the <code>var_x</code> parameter. The parameter value is a <em>variable name</em>.</li>
					<li>With the <code>text_x</code> parameter. The parameter value is a <em>text</em>.</li>
				</ul>
				(where <code>x</code> is either <code>a</code> or <code>b</code>).
			</p>
			<p>
				The operator is passed with the <code>op</code> parameter. Following parameters are available:
				<table>
				<thead>
					<tr>
						<th><code>op</code> value</th>
						<th>Description</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td><code>eq</code></td>
						<td>a and b are equal</td>
					</tr>
					<tr>
						<td><code>neq</code></td>
						<td>a and b are not equal</td>
					</tr>
					<tr>
						<td><code>lt</code></td>
						<td>a is less than b</td>
					</tr>
					<tr>
						<td><code>lte</code></td>
						<td>a is less or equal b</td>
					</tr>
					<tr>
						<td><code>gt</code></td>
						<td>a is greater than b</td>
					</tr>
					<tr>
						<td><code>gte</code></td>
						<td>a is greater or equal b</td>
					</tr>
				</tbody>
				</table>
			</p>
			<p>If the comparisons was true, a non-empty text will be returned, otherwise an empty text, so you can use ste:cmp with <a href="#builtin_if">ste:if</a> </p>
			<p>
				Example:<br />
<code><pre>&lt;ste:if&gt;<br />	&lt;ste:cmp var_a="foo" op="eq" text_b="bar" /&gt;<br />	&lt;ste:then&gt;:-)&lt;/ste:then&gt;<br />	&lt;ste:else&gt;:-(&lt;/ste:else&gt;<br />&lt;/ste:if&gt;</pre></code>
				If the variable <code>foo</code> has the content <code>bar</code>, <code>:-)</code> will be returned, <code>:-(</code> otherwise.
			</p>
			<h4 id="builtin_cmp_short">Short syntax for comparisons</h4>
				<p>Because comparisons are used often, there is an short syntax:</p>
				<p><code>~{a|operator|b}</code></p>
				<p>This is equivalent to:</p>
				<p><code>&lt;ste:cmp text_a="a" op="operator" text_b="b" /&gt;</code></p>
				<p><code>~</code>, <code>{</code>, <code>|</code> and <code>}</code> can be <a href="#escaping">escaped</a>.</p>
		
		<h3 id="builtin_not">ste:not</h3>
			<p>The ste:not Tag will logically invert its content. If it is an empty text (i.e. false), it will return a non-empty text (i.e. true) and vice versa.</p>
			<p>
				Example:<br />
<code><pre>&lt;ste:if&gt;<br />	&lt;ste:not&gt;$foo&lt;/ste:not&gt;<br />	&lt;ste:then&gt;:-)&lt;/ste:then&gt;<br />	&lt;ste:else&gt;:-(&lt;/ste:else&gt;<br />&lt;/ste:if&gt;</pre></code>
				If the variable <code>foo</code> is empty (i.e. false), <code>:-)</code> will be returned, <code>:-(</code> otherwise.
			</p>
		
		<h3 id="builtin_even">ste:even</h3>
			<p>If the enclosed text is a number, and the number is even, this tag will return a non-empty text (i.e. true), an empty text (i.e. false) otherwise.</p>
		
		<h3 id="builtin_for">ste:for</h3>
			<p>ste:for provides a counter loop.</p>
			<p>
				ste:for has these parameters:<br />
				<table>
				<thead>
					<tr>
						<th>parameter name</th>
						<th>Mandatory?</th>
						<th>Description</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td><code>start</code></td>
						<td>Yes</td>
						<td>Begin counting at this number.</td>
					</tr>
					<tr>
						<td><code>stop</code></td>
						<td>Yes</td>
						<td>Stop counting at this number (inclusive).</td>
					</tr>
					<tr>
						<td><code>step</code></td>
						<td>No</td>
						<td>What amount should be added to the counter at each round? (Default: 1)</td>
					</tr>
					<tr>
						<td><code>counter</code></td>
						<td>No</td>
						<td>The current number will be stored in this <a href="#basic_elems_variable">variable</a> (expects a variable name).</td>
					</tr>
				</tbody>
				</table>
			</p>
			<p>
				Example:<br />
<code><pre>&lt;ste:for start="10" stop="0" step="-1" counter="i"&gt;<br />	$i&lt;br /&gt;<br />&lt;/ste:for&gt;</pre></code>
				Will count from 10 down to 0 and output the number followed by an HTML line break.
			</p>
		
		<h3 id="builtin_foreach">ste:foreach</h3>
			<p>ste:foreach will loop through an array.</p>
			<p>
				ste:foreach has these parameters:<br />
				<table>
				<thead>
					<tr>
						<th>parameter name</th>
						<th>Mandatory?</th>
						<th>Description</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td><code>array</code></td>
						<td>Yes</td>
						<td>The array to be looped through (expects variable name).</td>
					</tr>
					<tr>
						<td><code>key</code></td>
						<td>No</td>
						<td>The array key will be stored in this variable (expects variable name).</td>
					</tr>
					<tr>
						<td><code>value</code></td>
						<td>Yes</td>
						<td>The value of the current element will be stored in this variable (expects variable name).</td>
					</tr>
					<tr>
						<td><code>counter</code></td>
						<td>No</td>
						<td>Expects a variable name. If given, the current number of iterations will be stored in this variable. Starts with 0.</td>
					</tr>
				</tbody>
				</table>
			</p>
			<p>
				Example:<br />
<code><pre>&lt;ste:foreach array="foo" key="k" value="v" counter="i"&gt;<br />	Number: $i&lt;br /&gt;<br />	Key: $k&lt;br /&gt;<br />	Value: $v&lt;br /&gt;<br />	&lt;br /&gt;<br />&lt;/ste:foreach&gt;</pre></code>
				This code will loop through the array <code>foo</code> and return the counter <code>$i</code>, the key <code>$k</code> and the value <code>$v</code> of the current iteration.
			</p>
		
		<h3 id="builtin_infloop">ste:infloop</h3>
			<p>Creates an infinitive loop. You can get out of the loop using the <a href="#builtin_break">ste:break</a> tag. Can be used to emulate other loop constructs like while loops.</p>
			<p>
				Example:<br />
<code><pre>&lt;ste:infloop&gt;<br />	&lt;ste:if&gt;<br />		&lt;ste:foo /&gt;<br />		&lt;ste:then&gt;&lt;ste:break /&gt;&lt;/ste:then&gt;<br />	&lt;/ste:if&gt;<br />	...<br />&lt;ste:infloop&gt;</pre></code>
				This code will return <code>...</code> while <code>&lt;ste:foo /&gt;</code> returns an empty text (i.e. false).
			</p>
		
		<h3 id="builtin_break">ste:break</h3>
			<p>When this self-closing tag is called, the current loop (<a href="builtin_for">ste:for</a>, <a href="builtin_foreach">ste:foreach</a>, <a href="builtin_infloop">ste:infloop</a>) will be aborted.</p>
		
		<h3 id="builtin_continue">ste:continue</h3>
			<p>When this self-closing tag is called, the current loop(<a href="builtin_for">ste:for</a>, <a href="builtin_foreach">ste:foreach</a>, <a href="builtin_infloop">ste:infloop</a>) will go to the next iteration, aborting the current iteration. </p>
		
		<h3 id="builtin_load">ste:load</h3>
			<p>This self-closing tag loads and executes another template. The <code>name</code> parameter (mandatory) defines the template to load.</p>
			<p>Because each template must be parseable and transcompilable by itself, this is not a inclusion of another template. So you can not do this:</p>
			<p>
				slave.tpl:<br />
<code><pre>&lt;ste:foo&gt;<br />	bla</pre></code>
				master.tpl<br />
<code><pre>&lt;ste:load name="slave.tpl" /&gt;<br />&lt;/ste:foo&gt;</pre></code>
			</p>
			<p>But you can do this:</p>
			<p>
				slave.tpl:<br />
<code><pre>&lt;ste:foo&gt;$bar&lt;/ste:foo&gt;</pre></code>
				master.tpl<br />
<code><pre>&lt;ste:baz&gt;<br />	&lt;ste:load name="slave.tpl" /&gt;<br />&lt;/ste:baz&gt;</pre></code>
			</p>
		
		<h3 id="builtin_block">ste:block</h3>
			<p>ste:block provides an easy way for writing master templates. Every block has a name. When a block is defined twice, the second one will overwrite the first one.</p>
			<p>The name can be set with the <code>name</code> parameter.</p>
			<p>
				Example:<br />
				master.tpl
<code><pre>&lt;h1&gt;Content:&lt;/h1&gt;<br />&lt;ste:block name="content"&gt;<br />	Default content<br />&lt;/ste:block&gt;<br />&lt;div class="sidebar"&gt;<br />	&lt;ste:block name="sidebar"&gt;<br />		Default sidebar<br />	&lt;/ste:block&gt;<br />&lt;/div&gt;</pre></code>
				slave.tpl:<br />
<code><pre>&lt;ste:load name="master.tpl" /&gt;<br />&lt;ste:block name="content"&gt;<br />	Much cooler content :-)<br />&lt;/ste:block&gt;</pre></code>
				When executing slave.tpl, master.tpl will be loaded and its <code>content</code> block will be replaced with the new one (<code>Much cooler content :-)</code>) but leave the original <code>sidebar</code> block.
			</p>
			<p>Blocks can not be nested.</p>
		
		<h3 id="builtin_set">ste:set</h3>
			<p>ste:set will set a variable. The parameter <code>var</code> takes the name of the variable to set. The content of the <a href="#basic_elems_tag">Tag</a> will be the new content of the variable.</p>
			<p>
				Example:<br />
<code><pre>&lt;ste:set var="foo"&gt;bar&lt;/ste:set&gt;</pre></code>
				This will set the variable <code>foo</code> to <code>bar</code>.
			</p>
			<p>
				<a href="#basic_elems_tag">Tag</a> parameter values can not contain Tags. ste:set can be used to bypass this:<br />
<code><pre>&lt;ste:set var="temp"&gt;&lt;ste:foo /&gt;&lt;/ste:set&gt;<br />&lt;ste:bar baz="$temp" /&gt;</pre></code>
			</p>
		
		<h3 id="builtin_get">ste:get</h3>
			<p>ste:get will return the content of a variable. The parameter <code>var</code> takes the name of the variable to get. Useful, if you want to get a variable which name is stored in a variable.</p>
			<p>
				Example:<br />
<code><pre>&lt;ste:get var="$foo" /&gt;</pre></code>
				This will get the variable with the name that is stored in the variable <code>foo</code>.
			</p>
		
		<h3 id="builtin_calc">ste:calc</h3>
			<p>To perform mathematical calculations, you can use ste:calc. ste:calc calculates the mathematical formula it is wrapped around and returns the result. The formula is in the usual <a href="http://en.wikipedia.org/wiki/Infix_notation">infix-notation [ext. Link]</a> and has these operators: <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code> and <code>^</code>. Numbers are always decimal, the decimal mark is <code>.</code> and numbers can be prefixed with an <code>-</code> to indicate a negative number. It is a good idea to wrap a negative number in brackets to prevent wrong evaluation (because <code>-</code> is also an operator). Calculations can be grouped with brackets: <code>(</code> and <code>)</code>.</p>
			<p>Real numbers are supported, complex numbers not.</p>
			<p>Formulas are evaluated at runtime, not during transcompilation.</p>
			<p>
				Example:<br />
				<code>&lt;ste:calc&gt;(2+3+4) * (1.5 - (-0.5))&lt;/ste:calc&gt;</code> will return <code>18</code>.
			</p>
			<p>This Tag is pretty slow, because the formula is not transcompiled and only evaluated at runtime. For some simple increment and decrement operations it is better to use the <a href="#stdlib_inc">ste:inc</a> and <a href="#stdlib_dec">ste:dec</a> Tags from the <a href="#stdlib">standard library</a>.</p>
		
		<h3 id="builtin_mktag">ste:mktag</h3>
			<p>ste:mktag allows you to define own <a href="#basic_elems_tag">Tags</a> using the STE Template Language.</p>
			<p>The parameter <code>name</code> (mandatory) expects the name of the new tag. If your tag requires some parameters, you can specify them using the optional <code>mandatory</code> parameter. Names of the mandatory parameters are separated by <code>|</code>.</p>
			<p>The <a href="#basic_elems_variable">Variable</a> <code>_tag_parameters</code> (associative array) will hold all given parameters and their values.</p>
			<p>With the ste:tagcontent tag you can execute the tags content.</p>
			<p>ste:mktag will be transcompiled like any other code. So your custom tag will be almost as fast as a plugin coded in PHP.</p>
			<p>
				Example:
<code><pre>&lt;ste:mktag name="countdown" mandatory="from|counter"&gt;<br />	&lt;ste:for start="$_tag_parameters[from]" stop="0" step="-1" counter="$_tag_parameters[counter]"&gt;<br />		&lt;ste:tagcontent /&gt;<br />	&lt;/ste:for&gt;<br />&lt;/ste:mktag&gt;<br />&lt;ste:mktag name="double"&gt;<br />	&lt;ste:calc&gt;&lt;ste:tagcontent /&gt; * 2&lt;/ste:calc&gt;<br />&lt;/ste:mktag&gt;<br />&lt;ste:countdown from="5" counter="i"&gt;<br />	&lt;ste:double&gt;$i&lt;/ste:double&gt;&lt;br /&gt;<br />&lt;/ste:countdown&gt;</pre></code>
				Will output:<br />
<code><pre>10&lt;br/&gt;<br />8&lt;br /&gt;<br />6&lt;br /&gt;<br />4&lt;br /&gt;<br />2&lt;br /&gt;<br />0&lt;br /&gt;</pre></code>
			</p>
		
	<h2 id="stdlib">Standard Library</h2>
		<p>The Standard Library contains some useful tags, which are not <a href="#builtin">builtin</a> but still always available.</p>
		<h3 id="stdlib_escape">ste:escape</h3>
			<p>Escapes characters that are reserved for HTML (e.g. <code>&lt;</code>, <code>&gt;</code>, <code>&quot;</code>, <code>&amp;</code>). The text to escape is the tag's content.</p>
			<p>
				Example:<br />
				<code><pre>&lt;ste:escape&gt;Foo &amp; bar...&lt;/ste:escape&gt;</pre></code>
				Result:<br />
				<code><pre>Foo &amp;amp; bar...</pre></code>
			</p>
			<p>
				If the optional parameter <code>lines</code> is true (i.e. not empty), then additionally line breaks are converted to <code>&lt;br /&gt;</code>.
			</p>
		
		<h3 id="stdlib_strlen">ste:strlen</h3>
			<p>Returns the length of then content.</p>
		
		<h3 id="stdlib_arraylen">ste:arraylen</h3>
			<p>Returns the number of elements in the array (variable name given by parameter <code>array</code>).</p>
		
		<h3 id="stdlib_inc">ste:inc</h3>
			<p>Increments (i.e. add 1) a variable (variable name given by parameter <code>var</code>).</p>
		
		<h3 id="stdlib_dec">ste:dec</h3>
			<p>Decrements (i.e. subtract 1) a variable (variable name given by parameter <code>var</code>).</p>
		
		<h3 id="stdlib_date">ste:date</h3>
			<p>Formats a time using PHPs <a href="http://php.net/manual/en/function.strftime.php">strftime format [ext. Link]</a>. The format is given in the tag's content. You can specify a time (unix timestamp) using the <code>timestamp</code> parameter (defaults to the current time).</p>
			<p>
				Example:<br />
				<code><pre>&lt;ste:date timestamp="1316357360"&gt;%d. %h. %Y, %H:%M:%S&lt;/ste:date&gt;</pre></code>
				Result:<br />
				<code><pre>18. Sep. 2011, 16:49:20</pre></code>
			</p>
		
		<h3 id="stdlib_in_array">ste:in_array</h3>
			<p>Check, if a value is in an array. The tag takes the variable name of the array by parameter <code>array</code>.The value to test with will be taken from the tags content.</p>
			<p>Returns empty text, if the value is not in the array, otherwise a non-empty text.</p>
		
		<h3 id="stdlib_join">ste:join</h3>
			<p>Join parts of an array together. The array's variable name goes to the <code>array</code> parameter. The tag's content will be used as the glue, i.e. this will be between two elements.</p>
			<p>Returns the joined array</p>
		
		<h3 id="stdlib_split">ste:split</h3>
			<p>Split a text and write the parts to an array. The <code>array</code> parameter takes the variable name of the resulting array, the <code>delim</code> parameter the text to split by. The tag's content will be the text to split.</p>
		
		<h3 id="stdlib_array_add">ste:array_add</h3>
			<p>Adding an element to an array. The <code>array</code> parameter takes the variable name of the array. The <code>key</code> parameter takes the array key to map the value to, if omitted, the value will be appended to the end of the array. The value is the tag's content.</p>
		
		<h3 id="stdlib_array_filter">ste:array_filter</h3>
			<p>Filter out array elements by multiple criterias.</p>
			<p>All the parameters are names of array variables.</p>
			<p><code>array</code> – The array to filter.</p>
			<p><code>keep_by_keys</code> – Keep elements with the keys in this array.</p>
			<p><code>keep_by_values</code> – Keep elements with the values in this array.</p>
			<p><code>delete_by_keys</code> – Delete elements with the keys in this array.</p>
			<p><code>delete_by_values</code> – Delete elements with the values in this array.</p>
</body>
</html>