From 9acc23d1ea3d0bf835595b1bc5d522900838a742 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Thu, 5 Jan 2012 02:28:05 +0100 Subject: Replaced the in the docu. Didn't work... --- docu/language_definition.html | 116 +++++++++++------------------------------- 1 file changed, 30 insertions(+), 86 deletions(-) (limited to 'docu/language_definition.html') diff --git a/docu/language_definition.html b/docu/language_definition.html index 1a633cc..575ea07 100644 --- a/docu/language_definition.html +++ b/docu/language_definition.html @@ -88,9 +88,9 @@

Also everything that is wrapped in the ste:rawtext pseudotag will be Text, whereby all Tags and Variables will not be parsed.

Example:

-

Foo $baz[herpdederp]]]>
+
<ste:rawtext>Foo <ste:bar>$baz[herpdederp]</ste:baz></ste:rawtext>
Will result in one text-element, but -
$baz[herpdederp]]]>
+
Foo <ste:bar>$baz[herpdederp]</ste:baz>
will result in one text-element and one tag-element containing one variable-element.

@@ -105,12 +105,12 @@

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 (barherpdederp]]>) 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" />

A Tag is wrapped in < and >. The tag's name always start with ste: and can then consist of letters, numbers and underscores (Regex: [a-zA-Z0-9_]+).

-

If the tag is self-closing, the last char is a / (e.g.: ]]>).

-

If the tag is a closing one, the first char is a /. An opening Tag does not have a /.An example of an opening-closing Tag pair wrapping the text bar: bar]]>

+

If the tag is self-closing, the last char is a / (e.g.: <ste:foo />).

+

If the tag is a closing one, the first char is a /. An opening Tag does not have a /.An example of an opening-closing Tag pair wrapping the text bar: <ste:foo>bar</ste:foo>

Parameters of a tag consists of a name and the corresponding value (wrapped in " 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!

-

Example: de ]]>

+

Example: <ste:foo bar="baz" herp="literal quote sign: \"">de <ste:derp hehe="hoho$wtf[xd]" /></ste:foo>

Pseudotag

Pseudotags look like normal tags, but they perform special tasks. There are currently two pseudotags:

@@ -208,18 +208,14 @@

The ste:then Tag is mandatory, the ste:else tag is optional.

Example:
-


-	$foo
-	Bar
-	Baz
-]]>
+
<ste:if>
$foo
<ste:then>Bar</ste:then>
<ste:else>Baz</ste:else>
</ste:if>
If $foo is not empty, then Bar will be executed, otherwise Baz.

Short syntax for if-clause

Because if-clauses are used often, there is an short syntax:

?{condition|then|else}

This is equivalent to:

-

conditionthenelse]]>

+

<ste:if>condition<ste:then>then</ste:then><ste:else>else</ste:else></ste:if>

?, {, | and } can be escaped

In this variant, the else part is not optional!

WARNING: short if-clauses can not be nested!

@@ -276,18 +272,14 @@

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:
-


-	
-	:-)
-	:-(
-]]>
+
<ste:if>
<ste:cmp var_a="foo" op="eq" text_b="bar" />
<ste:then>:-)</ste:then>
<ste:else>:-(</ste:else>
</ste:if>
If the variable foo has the content bar, :-) will be returned, :-( otherwise.

Short syntax for if-clause

Because comparisons are used often, there is an short syntax:

~{a|operator|b}

This is equivalent to:

-

]]>

+

<ste:cmp text_a="a" op="operator" text_b="b" />

~, {, | and } can be escaped

Because this is implemented as a simple substitution, you can only use Text and Variables. And " must be escaped.

WARNING: short comparisons can not be nested! They can be inside short if-clauses, but not the other way around!

@@ -296,11 +288,7 @@

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:
-


-	$foo
-	:-)
-	:-(
-]]>
+
<ste:if>
<ste:not>$foo</ste:not>
<ste:then>:-)</ste:then>
<ste:else>:-(</ste:else>
</ste:if>
If the variable foo is empty (i.e. false), :-) will be returned, :-( otherwise.

@@ -345,9 +333,7 @@

Example:
-


-	$i
-]]>
+
<ste:for start="10" stop="0" step="-1" counter="i">
$i<br />
</ste:for>
Will count from 10 down to 0 and output the number followed by an HTML line break.

@@ -389,12 +375,7 @@

Example:
-


-	Number: $i
- Key: $k
- Value: $v
-
-]]>
+
<ste:foreach array="foo" key="k" value="v" counter="i">
Number: $i<br />
Key: $k<br />
Value: $v<br />
<br />
</ste:foreach>
This code will loop through the array foo and return the counter $i, the key $k and the value $v of the current iteration.

@@ -402,13 +383,7 @@

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:
-


-	
-		
-		
-	
-	...
-]]>
+
<ste:infloop>
<ste:if>
<ste:foo />
<ste:then><ste:break /></ste:then>
</ste:if>
...
<ste:infloop>
This code will return ... while <ste:foo /> returns an empty text (i.e. false).

@@ -423,20 +398,16 @@

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]]>
+
<ste:foo>
bla
master.tpl
-

-]]>
+
<ste:load name="slave.tpl" />
</ste:foo>

But you can do this:

slave.tpl:
-

$bar]]>
+
<ste:foo>$bar</ste:foo>
master.tpl
-

-	
-]]>
+
<ste:baz>
<ste:load name="slave.tpl" />
</ste:baz>

ste:block

@@ -445,20 +416,9 @@

Example:
master.tpl -

Content:
-
-	Default content
-
-]]>
+
<h1>Content:</h1>
<ste:block name="content">
Default content
</ste:block>
<div class="sidebar">
<ste:block name="sidebar">
Default sidebar
</ste:block>
</div>
slave.tpl:
-

-
-	Much cooler content :-)
-]]>
+
<ste:load name="master.tpl" />
<ste:block name="content">
Much cooler content :-)
</ste:block>
When executing slave.tpl, master.tpl will be loaded and its 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]]>
+
<ste:set var="foo">bar</ste:set>
This will set the variable 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" />

ste:calc

@@ -482,7 +441,7 @@

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: -


-	
-		
-	
-
-
-	 * 2
-
-
-	$i
-
]]>
+
<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>
Will output:
-

-8
-6
-4
-2
-0
]]>
+
10<br/>
8<br />
6<br />
4<br />
2<br />
0<br />

Standard Library

@@ -520,9 +464,9 @@

Escapes characters that are reserved for HTML (e.g. <, >, ", &). The text to escape is the tag's content.

Example:
-

Foo & bar...]]>
+
<ste:escape>Foo & bar...</ste:escape>
Result:
-
+
Foo &amp; bar...

ste:strlen

@@ -541,9 +485,9 @@

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]]>
+
<ste:date timestamp="1316357360">%d. %h. %Y, %H:%M:%S</ste:date>
Result:
-
+
18. Sep. 2011, 16:49:20

-- cgit v1.2.3-70-g09d2