From 9acc23d1ea3d0bf835595b1bc5d522900838a742 Mon Sep 17 00:00:00 2001
From: Kevin Chabowski Also everything that is wrapped in the ste:rawtext pseudotag will be Text, whereby all Tags and Variables will not be parsed.
- A Tag can be compared to a function. A Tag can have parameters and children elements.
A Tag looks like a XML-Tag with the ste-Namespace.
- Just like their XML counterparts, they can wrap other elements ( A Tag is wrapped in
- If the tag is self-closing, the last char is a If the tag is a closing one, the first char is a If the tag is self-closing, the last char is a If the tag is a closing one, the first char is a
Parameters of a tag consists of a name and the corresponding value (wrapped in Example: Example: Pseudotags look like normal tags, but they perform special tasks. There are currently two pseudotags: The ste:then Tag is mandatory, the ste:else tag is optional.
Example: Because if-clauses are used often, there is an short syntax: This is equivalent to: In this variant, the else part is not optional! WARNING: short if-clauses can not be nested! If the comparisons was true, a non-empty text will be returned, otherwise an empty text, so you can use ste:cmp with ste:if
Example: Because comparisons are used often, there is an short syntax: This is equivalent to: Because this is implemented as a simple substitution, you can only use Text and Variables. And WARNING: short comparisons can not be nested! They can be inside short if-clauses, but not the other way around! 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.
Example:Example:
+ Foo
Will result in one text-element, but
- <ste:rawtext>Foo <ste:bar>$baz[herpdederp]</ste:baz></ste:rawtext>
+ $baz[herpdederp]]]>
will result in one text-element and one tag-element containing one variable-element.
Foo <ste:bar>$baz[herpdederp]</ste:baz>
bar) or can be self-closing (]]>).
- And they can have additional parameters (or "attributes", using the XML terminology): ]]>
+ Just like their XML counterparts, they can wrap other elements (<ste:foo>bar<ste:baz>herpdederp</ste:baz></ste:foo>) or can be self-closing (<ste:foo />).
+ And they can have additional parameters (or "attributes", using the XML terminology): <ste:foo bar="baz" />
< and >. The tag's name always start with ste: and can then consist of letters, numbers and underscores (Regex: [a-zA-Z0-9_]+)./ (e.g.: ]]>)./. An opening Tag does not have a /.An example of an opening-closing Tag pair wrapping the text bar: bar]]>/ (e.g.: <ste:foo />)./. An opening Tag does not have a /.An example of an opening-closing Tag pair wrapping the text bar: <ste:foo>bar</ste:foo>" or ') separated by an = .
Parameters are separated by any whitespace (space, tab or newline) char.
@@ -118,7 +118,7 @@
If you need a literal " or ' in a parameter value, you can escape them: \" or \' .
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 foo="$bar", the tag will not operate on the bar variable but on the Variable with the name stored in $bar! So read the instructions to the tag carefully!
de <ste:foo bar="baz" herp="literal quote sign: \"">de <ste:derp hehe="hoho$wtf[xd]" /></ste:foo>Pseudotag
-
+
- $foo
-
If <ste:if>
$foo
<ste:then>Bar</ste:then>
<ste:else>Baz</ste:else>
</ste:if>$foo is not empty, then Bar will be executed, otherwise Baz.
Short syntax for if-clause
?{condition|then|else}condition<ste:if>condition<ste:then>then</ste:then><ste:else>else</ste:else></ste:if>?, {, | and } can be escaped
-
+
-
If the variable <ste:if>
<ste:cmp var_a="foo" op="eq" text_b="bar" />
<ste:then>:-)</ste:then>
<ste:else>:-(</ste:else>
</ste:if>foo has the content bar, :-) will be returned, :-( otherwise.
Short syntax for if-clause
~{a|operator|b}]]><ste:cmp text_a="a" op="operator" text_b="b" />~, {, | and } can be escaped" must be escaped.
-
+
-
If the variable <ste:if>
<ste:not>$foo</ste:not>
<ste:then>:-)</ste:then>
<ste:else>:-(</ste:else>
</ste:if>foo is empty (i.e. false), :-) will be returned, :-( otherwise.
Example:
-
+
- $i
-]]>
Will count from 10 down to 0 and output the number followed by an HTML line break.
<ste:for start="10" stop="0" step="-1" counter="i">
$i<br />
</ste:for>
Example:
-
+
- Number: $i
- Key: $k
- Value: $v
-
-]]>
This code will loop through the array <ste:foreach array="foo" key="k" value="v" counter="i">
Number: $i<br />
Key: $k<br />
Value: $v<br />
<br />
</ste:foreach>foo and return the counter $i, the key $k and the value $v of the current iteration.
Create an infinitive loop. You can get out of the loop using the ste:break tag. Can be used to emulate other loop constructs like while loops.
Example:
-
+
-
This code will return <ste:infloop>
<ste:if>
<ste:foo />
<ste:then><ste:break /></ste:then>
</ste:if>
...
<ste:infloop>... while <ste:foo /> returns an empty text (i.e. false).
Because each template must be parseable and transcompilable by itself, this is not a inclusion of another template. So you can not do this:
slave.tpl:
-
+
- bla]]>
master.tpl<ste:foo>
bla
-
+
-]]>
<ste:load name="slave.tpl" />
</ste:foo>
But you can do this:
slave.tpl:
-
+$bar]]>
master.tpl<ste:foo>$bar</ste:foo>
-
+
-
<ste:baz>
<ste:load name="slave.tpl" />
</ste:baz>
Example:
master.tpl
-
+Content:
-
slave.tpl:<h1>Content:</h1>
<ste:block name="content">
Default content
</ste:block>
<div class="sidebar">
<ste:block name="sidebar">
Default sidebar
</ste:block>
</div>
-
+
-
When executing slave.tpl, master.tpl will be loaded and its <ste:load name="master.tpl" />
<ste:block name="content">
Much cooler content :-)
</ste:block>content block will be replaced with the new one (Much cooler content :-)) but leave the original sidebar block.
Blocks can not be nested.
@@ -467,13 +427,12 @@ste:set will set a variable. The parameter var takes the name of the variable to set. The content of the Tag will be the new content of the variable.
Example:
-
+bar]]>
This will set the variable <ste:set var="foo">bar</ste:set>
foo to bar.
Tag parameter values can not contain Tags. ste:set can be used to bypass this:
-
+<ste:set var="temp"><ste:foo /></ste:set>
<ste:bar baz="$temp" />
Formulas are evaluated at runtime, not during transcompilation.
Example:
- (2+3+4) * (1.5 - (-0.5))]]> will return 18.
+ <ste:calc>(2+3+4) * (1.5 - (-0.5))</ste:calc> will return 18.
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 ste:inc and ste:dec Tags from the standard library.
@@ -494,24 +453,9 @@ste:mktag will be transcompiled like any other code. So your custom tag will be almost as fast as a plugin coded in PHP.
Example:
-
+
-
-
Will output:<ste:mktag name="countdown" mandatory="from|counter">
<ste:for start="$_tag_parameters[from]" stop="0" step="-1" counter="$_tag_parameters[counter]">
<ste:tagcontent />
</ste:for>
</ste:mktag>
<ste:mktag name="double">
<ste:calc><ste:tagcontent /> * 2</ste:calc>
</ste:mktag>
<ste:countdown from="5" counter="i">
<ste:double>$i</ste:double><br />
</ste:countdown>
-
+
-8
-6
-4
-2
-0
]]>10<br/>
8<br />
6<br />
4<br />
2<br />
0<br />
Escapes characters that are reserved for HTML (e.g. <, >, ", &). The text to escape is the tag's content.
Example:
-
+ Foo & bar...]]>
Result:<ste:escape>Foo & bar...</ste:escape>
-
+ Foo & bar...
Formats a time using PHPs strftime format [ext. Link]. The format is given in the tag's content. You can specify a time (unix timestamp) using the timestamp parameter (defaults to the current time).
Example:
-
+ %d. %h. %Y, %H:%M:%S]]>
Result:<ste:date timestamp="1316357360">%d. %h. %Y, %H:%M:%S</ste:date>
-
+ 18. Sep. 2011, 16:49:20