Default modificators

donnerjack13589 edited this page Aug 31, 2010 · 4 revisions

nTPL supports modificators (for more detailed info How to write module).

Some of them are included in default package (nTPL) and can be used while you’re creating/editing your template.
Here comes full list:

  • set ( {%set name ... %} , {%set args ..., ..., ... %} ) – used to set/change template name or arguments
  • set ( {%set foo.bar.bla val1, ..., valMany %} ) -used to set/change module configs
  • = ( {%= "some value" %} ) – used to print text or something to buffer
  • if ( {%if some_value %}...{%/if%} ) – no comments
  • else ( {%if some_value %}...{%else %}...{%/if%} )
  • elseif ( {%if some_value %}...{%elseif other_value %}...{%/if%} )
  • each ( {%each obj_or_array %}...{%= $i %}...{%= this %}...{%/each %} ) – walk through object fields or array items. this will hold value of property/item, $i will hold index or property name
  • catch ({%catch var_name%}...{%/catch %} ) – all printed to buffer text between catch braces will be put into var_name

Note that there must be no space between {% and modificator’s name.
So following example is incorrect:
{% if something %} ... {% /if %}