From b52413dbb4d8333d5fe2a351780e20b04c4525a2 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Tue, 14 Apr 2015 22:37:15 +0200 Subject: Trim whitespace --- docu/language_definition.html | 76 +++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'docu/language_definition.html') diff --git a/docu/language_definition.html b/docu/language_definition.html index 08bacb7..8fef8f0 100644 --- a/docu/language_definition.html +++ b/docu/language_definition.html @@ -24,12 +24,12 @@ background: #eee; } - +

The STE Template Language

This is the documentation of the Template Language of the STE Template Engine.

- +

TOC

  1. @@ -86,10 +86,10 @@
- +

Basic Elements

The STE Template Language consists of four basic elements:

- +

Text

Everything that is not a Variable, a Tag or a Pseudotag is Text.

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

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

- +

Variable

Variables start with a $ or can be wrapped within ${ and }, so you can write this: ${foo}ish

Variable have names, these names can consist of letters (english alphabet; upper and lower case), numbers and underscores (_). As a regex: [a-zA-Z0-9_]+

A variable can also be an array. To access an array, wrap the desired fieldname within [ and ]. A fieldname can be constructed of Text and other Variables. So you can dynamically access fields: $foo[$bar]. These fieldnames can also be nested or concatenated: $foo[$bar[baz]][herp][$de[derp]]

If you want a literal $ char, you can escape it: \$

Variables in STE are typeless, everything is text. In a boolean context, empty text usually represents false, else true.

- +

Tag

A Tag can be compared to a function. A Tag can have parameters and children elements.

@@ -126,14 +126,14 @@ 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: <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:

ste:comment

With the ste:comment pseudotag you can comment your template/code. Everything between <ste:comment> and </ste:comment> will be ignored, before the real tokenization of the code starts.

ste:rawtext

The ste:rawtext pseudotag will output a Text element with its wrapped content. It will prevent parsing of the content. Useful if you are embedding another script language, which uses the $ char or also has a XML-Like syntax. No escape sequences will be translated! Can not be used in Tag parameter values!

- +

Escaping special chars

To get a literal $, " or other special chars, STE gives you the following escape sequences:

@@ -203,10 +203,10 @@

Escape sequences are not translated in Pseudotags

- +

Builtin Tags

STE has some builtin Tags, that makes programming in STE possible.

- +

ste:if

The ste:if Tag provides an if-clause to STE.

ste:if can have the subtags ste:then and ste:else. Everything between <ste:if> and </ste:if>, that is not an ste:then or ste:else tag, will be used as the condition.

@@ -225,7 +225,7 @@

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

- +

ste:cmp

With the ste:cmp tag you can compare two values.

ste:cmp is selfclosing, the compared values are passed by parameters.

@@ -287,7 +287,7 @@

This is equivalent to:

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

~, {, | and } can be escaped.

- +

ste:not

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.

@@ -295,10 +295,10 @@

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

- +

ste:even

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.

- +

ste:for

ste:for provides a counter loop.

@@ -340,7 +340,7 @@

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

- +

ste:foreach

ste:foreach will loop through an array.

@@ -390,7 +390,7 @@

<ste:foreach array="foo" value="v">
<p>$v</p>
<ste:else>
Array \$foo is empty.
</ste:else>
</ste:foreach>
This code will list all array elements or will display Array $foo is empty if the array $foo is empty.

- +

ste:infloop

Creates 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.

@@ -398,13 +398,13 @@

<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).

- +

ste:break

When this self-closing tag is called, the current loop (ste:for, ste:foreach, ste:infloop) will be aborted.

- +

ste:continue

When this self-closing tag is called, the current loop(ste:for, ste:foreach, ste:infloop) will go to the next iteration, aborting the current iteration.

- +

ste:load

This self-closing tag loads and executes another template. The name parameter (mandatory) defines the template to load.

Because each template must be parseable and transcompilable by itself, this is not a inclusion of another template. So you can not do this:

@@ -421,7 +421,7 @@ master.tpl
<ste:baz>
<ste:load name="slave.tpl" />
</ste:baz>

- +

ste:block

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.

The name can be set with the name parameter.

@@ -434,7 +434,7 @@ 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.

- +

ste:set

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.

@@ -446,10 +446,10 @@ 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:set

ste:setlocal is used like ste:set, but only a local variable will be set (ste:set would overwrite a variable, if it was declared in a parent scope). - +

ste:get

ste:get will return the content of a variable. The parameter var takes the name of the variable to get. Useful, if you want to get a variable which name is stored in a variable.

@@ -457,7 +457,7 @@

<ste:get var="$foo" />
This will get the variable with the name that is stored in the variable foo.

- +

ste:calc

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 infix-notation [ext. Link] and has these operators: +, -, *, / and ^. Numbers are always decimal, the decimal mark is . and numbers can be prefixed with an - to indicate a negative number. It is a good idea to wrap a negative number in brackets to prevent wrong evaluation (because - is also an operator). Calculations can be grouped with brackets: ( and ).

Real numbers are supported, complex numbers not.

@@ -467,7 +467,7 @@ <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.

- +

ste:mktag

ste:mktag allows you to define own Tags using the STE Template Language.

The parameter name (mandatory) expects the name of the new tag. If your tag requires some parameters, you can specify them using the optional mandatory parameter. Names of the mandatory parameters are separated by |.

@@ -480,7 +480,7 @@ Will output:
10<br/>
8<br />
6<br />
4<br />
2<br />
0<br />

- +

Standard Library

The Standard Library contains some useful tags, which are not builtin but still always available.

ste:escape

@@ -494,26 +494,26 @@

If the optional parameter lines is true (i.e. not empty), then additionally line breaks are converted to <br />.

- +

ste:autoescape

Sets the autoescaping method in its content. Autoescaping escapes all variables that are not part of an argument of an STE tag. By default, autoescaping is turned off (mode none) due to backwards compatibility with old versions of STE.

The parameter mode is mandatory and can be one of none (no escaping) or html (escape as HTML).

- +

ste:raw

<ste:raw>...</ste:raw> is an alias for <ste:autoescape mode="none">...<<ste:autoescape> - +

ste:strlen

Returns the length of then content.

- +

ste:arraylen

Returns the number of elements in the array (variable name given by parameter array).

- +

ste:inc

Increments (i.e. add 1) a variable (variable name given by parameter var).

- +

ste:dec

Decrements (i.e. subtract 1) a variable (variable name given by parameter var).

- +

ste:date

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).

@@ -522,21 +522,21 @@ Result:

18. Sep. 2011, 16:49:20

- +

ste:in_array

Check, if a value is in an array. The tag takes the variable name of the array by parameter array.The value to test with will be taken from the tags content.

Returns empty text, if the value is not in the array, otherwise a non-empty text.

- +

ste:join

Join parts of an array together. The array's variable name goes to the array parameter. The tag's content will be used as the glue, i.e. this will be between two elements.

Returns the joined array

- +

ste:split

Split a text and write the parts to an array. The array parameter takes the variable name of the resulting array, the delim parameter the text to split by. The tag's content will be the text to split.

- +

ste:array_add

Adding an element to an array. The array parameter takes the variable name of the array. The key 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.

- +

ste:array_filter

Filter out array elements by multiple criterias.

All the parameters are names of array variables.

-- cgit v1.2.3-54-g00ecf