Marker-TPL Syntax Explanation
1. MARKERS
* with optional escapings or transformers
[###MARKER###] with optional escapings or transformers that may be combined in logic chains: [###MARKER|bool###], [###MARKER|int###], [###MARKER|dec{1..4}###], [###MARKER|num###], [###MARKER|slug|lower###], [###MARKER|htmid###], [###MARKER|jsvar###], [###MARKER|json###], [###MARKER|lower###], [###MARKER|upper###], [###MARKER|ucfirst###], [###MARKER|ucwords###], [###MARKER|trim###], [###MARKER|substr{1..65535}###], [###MARKER|subtxt{5..65535}###], [###MARKER|url###], [###MARKER|js###], [###MARKER|html###], [###MARKER|nl2br###], [###MARKER|url|js###], [###MARKER|html|nl2br###], [###MARKER|trim|js|html###], [###MARKER|dec2|url###], [###MARKER|js|html###], [###MARKER|css|html###], ..., [###MARKER|url|js|html###], ...)
2. SPECIAL CHARACTERS and COMMENTS
* special characters can be used in templates to assure consistency
* commented code in a template will not be rendered at all
[%%%|SB-L%%%] ensures a LEFT SQUARE BRACKET [
[%%%|SB-R%%%] ensures a RIGHT SQUARE BRACKET ]
[%%%|SPACE%%%] ensures a SPACE ⎵
[%%%|T%%%] ensures a TAB \t
[%%%|N%%%] ensures a LINE FEED \n
[%%%|R%%%] ensures a CARRIAGE RETURN \r
[%%%|R%%%][%%%|N%%%] ensures a CRLF (CARRIAGE RETURN + LINE FEED) \r\n
[%%%COMMENT%%%] This text will never be displayed and will be cut off when rendering this template [%%%/COMMENT%%%]
3. IF / ELSE [**]
* conditionals are available with optional ELSE syntax
[%%%IF:VARIABLE:@==|@!=|@<=|@<|@>=|@>|==|!=|<=|<|>=|>|!%|%|!?|?|^~|^*|&~|&*|$~|$*{string/number/a|list|with|elements/###MARKER###};%%%]
conditional IF part, display when condition is matched
[%%%ELSE:VARIABLE%%%]
conditional ELSE part, display otherwise (optional)
[%%%/IF:VARIABLE%%%]
4. LOOP [**]
* expect associative array: (by key/val) or non-associative (by iterator)
[%%%LOOP:ARRAY-VAR%%%]
Rendering of Loop syntax is depending upon the array type ; it can be combined with IF / ELSE and the other syntax elements ...
* if ARRAY-VAR is a NON-ASSOCIATIVE ARRAY [0=>[row]..n=>[row]] can display for each row the columns 'column-A', 'column-N' which are as ARRAY-VAR[i][column-a] and ARRAY-VAR[i][column-n] where 'i' is the row number for non-associative array and 'row' is an associative array of key/val pairs which must contain at least the keys (columns) 'column-a' and 'column-n' such as: [###ARRAY-VAR.COLUMN-A|int###], [###ARRAY-VAR.COLUMN-B|html###]
* if ARRAY-VAR is an ASSOCIATIVE ARRAY [key1=>val1,...,keyN=>valueN] can display for each key/value pair: [###ARRAY-VAR._-KEY-_|html###] = [###ARRAY-VAR._-VAL-_|trim|html###]
[%%%/LOOP:ARRAY-VAR%%%]
5. INCLUDE Sub-Template [**]
* can include subtemplates mandatory or optional, includding make use of variable path
[@@@SUB-TEMPLATE:the-main-tpl-relative-path/partials/the-partial-tpl-to-be-includded.inc.htm@@@] mandatory include a partial from the same directory under the sub-directory 'partials'
[@@@SUB-TEMPLATE:!web-dir/relative/tpl-path/the-partial-tpl-to-be-includded.inc.htm!@@@] mandatory include a partial from another directory, from inside the app web root
[@@@SUB-TEMPLATE:?!web-dir/relative/tpl-alternate-path/the-partial-tpl-to-be-includded-if-exists-only.inc.htm!@@@] optional include a partial from another alternate directory, from inside the app web root
[@@@SUB-TEMPLATE:%variable-relative-path-of-sub-tpl-to-include%@@@]
mandatory include a variable path partial which is set at the controller level in the section: '%variable-relative-path-of-sub-tpl-to-include%'
[**]: Feature is currently supported only when rendering a Marker-TPL Template from server-side PHP (not also if rendering it directly from client-side Javascript)