vlibTemplate

vLib Logo

5. Tags

Note: even though these tags look like HTML they are a little different as they're allowed to "break the rules". Something like:

Template
   <p><tmpl_var name='body_text'></p>

In Dreamweaver or other editors it might be more convenient to see the vLIB markup tags. You can use "{}" instead of "<>". Most examples use this alternative syntax.

Template
   <p>{tmpl_var name='body_text'}</p>

These markup tags are not really valid HTML (or XHTML), but it will work as planned. TMPL_VAR specifies a template variable. The attribute "name" is necessary to create the interface between the PHP script and the template.

The "TMPL_" bit of the tag is optional, and can be omitted if you prefer to use the shorter versions, i.e.: <LOOP name="LOOP_NAME">.

If you're a fanatic about valid HTML and would like your templates to conform to valid HTML syntax, you may optionally type template tags in the form of HTML comments. This may be of use to HTML authors who would like to validate their templates' HTML syntax prior to vlibTemplate parsing, or who use DTD-savvy editing tools. You can also use " instead of ' or you can disable it completly, but I would not recommend it.

Template
   <p><!-- tmpl_var name='param1' --></p>

You can also use a curly bracket syntax '{tmpl_var}' for use within comments (as to not break them with the comment style tag), or within html tags (as to not break the tag in your editor).

Template
   <p>{tmpl_var name=param1}</p>

All shown brackets should work with all vLIB markup tags.



5.1. TMPL_VAR name='VARNAME'
5.2. TMPL_LOOP name='LOOP_NAME'
5.3. TMPL_INCLUDE name='filename.html'
5.4. TMPL_PHPINCLUDE name='filename.html'
5.5. TMPL_[ELSE]IF name='BOOL'
5.6. TMPL_ELSE
5.7. TMPL_UNLESS name='BOOL'