Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

4. Template Directives > Defining Local Template Blocks

Defining Local Template Blocks

Sometimes, particularly in a project that involves a large number of small templates, it doesn’t seem very efficient to create an external file for every template that you need. The BLOCK ... END construct can be used to avoid this. It allows you to define template component blocks that can be processed with the INCLUDE, PROCESS, and WRAPPER directives.

[% BLOCK tabrow %]
<tr><td>[% name %]<td><td>[% email %]</td></tr>
[% END %]

<table>
[% PROCESS tabrow  name='Fred'  email='fred@nowhere.com' %]
[% PROCESS tabrow  name='Alan'  email='alan@nowhere.com' %]
</table>

A BLOCK definition can be used before it is defined, as long as the definition resides in the same file. The block definition itself does not generate any output.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint