vlibTemplate

vLib Logo

5.1. <TMPL_VAR name='VARNAME'>

The <TMPL_VAR> tag is very simple. For each <TMPL_VAR> tag in the template you call $tmpl->setvar('VARNAME', "VALUE").

When the template is output the <TMPL_VAR> is replaced with the VALUE text you specified.

Optionally there are 2 more attributes that you can add to this tag:

1) Escape .. value may be:

i) html -> html escapes the variable, i.e. exchanging '<' with '&lt;' , '>' with '&gt;' and '&' with '&amp;'.

ii) url -> url escpaes the string, i.e. exchanging ' ' with '+' and '/' with '%2F.

iii) sq -> escapes single quotes within a string, i.e. "I can't" becomes "I can\'t".

iv) dq -> escapes doubles quotes within a string, i.e. 'she said: "Hello!".' becomes 'she said: \"Hello!\".'

v) none -> turns off any escaping for this particular variable.

2) Format .. value may be:

i) strtoupper -> transforms var to upper case.

ii) uc -> same as strtoupper (upper case).

iii) strtolower -> transforms var to lower case.

iv) lc -> same as strtolower (lower case).

v) ucfirst -> makes the first character of the var uppercase.

vi) lcucfirst -> first transforms the var to lower case, then does a ucfirst on it.

vii) ucwords -> makes the first character of every word in the var upper case.

viii) lcucwords -> first transforms var to lower case, then does a ucwords on it.

Both of these tags may have extra elements added at any time. If in the future you need something added, then visit vLIB support and if we think it's feasable, we'll add it.

Here's an example of a complete tag:

Example
   My e-mail is: <TMPL_VAR NAME='email' escape='html' format='lc'>.