Marker-TPL, a powerful and secure Templating Engine: |
Marker-TPL Templating Demo |
As an alternative to the Marker-TPL Templating Engine syntax (built-in, default) it is possible to use alternatives:
Twist Templating Engine (Twig like Grammar but much safer, implementing Liquid like Safety) syntax to render Views of Smart.Framework by using the Smart.Framework.Module: mod-tpl-twist
or is possible to use
Twig Templating Engine syntax to render Views of Smart.Framework by using the Smart.Framework.Module: mod-tpl-twig.
And as a premium feature you can use the flavoured XML DOM parser based Typo3-Fluid Templating Engine syntax (which is available in Smart.Framework.Modules: mod-tpl-typo3-fluid). If you are not satisfied with any of these you can create new custom Smart.Framework.Modules to integrate other TPL engines such as Smarty or PHP Plates for use with Smart.Framework. |
Twist Templating Demo (extra modules)
Twig Templating Demo (extra modules) Typo3-Fluid Templating Demo (extra modules) |
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%' |
TPL Render Test: Marker-TPL Templating - Basic Syntax | ||
---|---|---|
Column 1.x (HTML Escape) | Column 2.x (JS Escape) | Column 3.x (URL Escape) |
<Column 1.1> | Column 1.2\n | Column%201.3%09 |
<Column 2.1> | Column 2.2\n | Column%202.3%09 |
<Column 3.1> | Column 3.2\n | Column%203.3%09 |
1 [ >= 1 ; C2 = a ] | a | A |
1 * 0.123456789 (Numeric Escape) |
{ "base": "2856436323828330887581965677492027452358764572215142758165522326241696729675650630522398099165763441849173654830206216348742045975374612082476873006275820", "prix": "default", "sec": "4336761981534019664283509403670907118004992645974049123627825889194648040057022476791959804377907118501194412300377097995925301884750581871660729128966555", "pub": "2404543688667911716372842917030920695793457491176424551664925" }Client-Data (debug only):