Template-Toolkit


Create dinamic HTML with the help of Template-Toolkit

Template-Toolkit is a powerful tool that makes possible a lot of Zera functions, so it's important to know the basics about it. To call any function or value from TT you need to type it inside <% and %>. Very important to left a space between the symbols and the functions you wish to call.

Note

First of all, by default TT uses [] to call it's functions, but here in Zera they're replaced by <>, so, insted of calling the functions by writting:

[% function %]

You have to type:

<% function %>

Zera returns many values to the webpage. To display them you need to call the values through TT.

If a functions returns the values:

my $var = {
  values1 => $values1,
  values2 => $values2,
  num => $number
};

You need to read them like:

<% values1 %>
<% values2 %>

This will print the values of each variable into a label.

If any of this values is an array displaying them in this way will result in an error. To display an array you have 2 options:

Index

You can print an individual value by specifying it in the code:

<% values1.0 %>
<% values2.$num %>

The first example will print the value of the first element in the array. The second example will print the value in the position that the variable $num tells.

FOREACH cycle

You can also print all the values of the array using a FOREACH cycle.

<% FOREACH value = values %>
<% END %>

To know more about Template-Toolkit please go to i'ts website.