Template Engine

A guide for the new template engine will hopefully follow soon.


parent file -> template

  1. how do templates work
  2. concept and internals
  3. $tpl->naming
  4. how to process conditions
  5. how to use filters

add an example template with all cases and examples into the community folder

  1. action/template.php
  2. action/template/template.tpl

classes

  1. templatest.php
  2. templatestescaper.php
  3. templatestfilters.php
  4. templatestsetter.php
  5. templatestuser.php

Workflow


Base File

example.php


setting and leaving prefixes
$tpl->enter('menu_');


$tpl->leave();

Template File

example.tpl


.include ../../../_common/_header.tpl


[ ' nonstatic ' ]


['' commit | void // alternation hack '']

Syntax

[ === main === ]


[== sortsArr ==]


[= UserList =]


[ ==== // some text === ] comment


[''' l UserList ''']


['' pagination '']


[ ' link ' ]


['' // comment '']

Inline definitions


[ ==== abc def ==
   ....
 ===== ]


cut off old [= ... =] block, and replace it with lone recall line

Pull

[ ' csrf: login ' ]


[ ' db: pwd_min_chars ' ]


[ ' format_t: ForgotLink ' ]


[ ' href: properties ' ]


[ ' _t: RealName ' ]

Filters

[ ' comments | check 2 ' ]


[' note |e ']


[ ' username |e attr ' ]


[ ' page.hits | number 0 , . ' ]


[ ' created | time_formatted ' ]


['' a | replace desc uarr asc darr '']


[ ' count | enclose " (" ")" ' ]


[ ' preview | nl2br ' ]

Examples

Hints

Possible error sources


creates new array -> EXPLAIN, keep them in order
$tpl->a_b_c
$tpl->a_b


same array
$tpl->a_b
$tpl->a_b_c