convert_file($filename)
Receives an absolute path to a template file, converts that file to Perl code by calling convert() and
returns that code.
convert($input,[$filename])
Receives a text of a template (i.e. the template itself) and possibly an absolute path to the template
file (if the template comes from a file), and converts the template into Perl code, which is later
"eval"uated for rendering. Conversion is done by parsing the statements in the template (see
parse_stmt()).
compile_stmt_pattern($pl)
Receives a string which denotes the Perl code delimiter which is used inside templates. Tenjin uses
'"<?pl ... ?>"' and '"<?PL ... ?>"' (the latter for preprocessing), so $pl will be 'pl'. This method
returns a tranlsation regular expression which will be used for reading embedded Perl code.
stmt_pattern
Returns the default pattern (which uses 'pl') with the previous_method.
expr_pattern()
Defines how expressions are written in Tenjin templates ("[== $expr =]" and "[= $expr =]").
parse_stmt($bufref,$input)
Receives a buffer which is used for saving a template's expressions and the template's text, parses all
expressions in the templates and pushes them to the buffer.
hook_stmt($stmt)expand_macro($funcname,$arg)
This method is in charge of invoking macro functions which might be used inside templates. The following
macros are available:
• include( $filename )
Includes another template, whose name is $filename, inside the current template. The included
template will be placed inside the template as if they were one unit, so the context variable applies
to both.
• start_capture( $name ) and end_capture()
Tells Tenjin to capture the output of the rendered template from the point where start_capture() was
called to the point where end_capture() was called. You must provide a name for the captured portion,
which will be made available in the context as "$_context->{$name}" for immediate usage. Note that
the captured portion will not be printed unless you do so explicilty with "$_context->{$name}".
• start_placeholder( $var ) and end_placeholder()
This is a special method which can be used for making your templates a bit cleaner. Suppose your
context might have a variable whose name is defined in $var. If that variable exists in the context,
you simply want to print it, but if it's not, you want to print and/or perform other things. In that
case you can call start_placeholder( $var ) with the name of the context variable you want printed,
and if it's not, anything you do between start_placeholder() and end_placeholder() will be printed
instead.
• echo( $exr )
Just prints the provided expression. You might want to use it if you're a little too comfortable with
PHP.
get_expr_and_escapeflag($not_escape,$expr,$delete_newline)parse_expr($bufref,$input)start_text_part($bufref)stop_text_part($bufref)add_text($bufref,$text)add_stmt($bufref,$stmt)add_expr($bufref,$expr,$flag_escape)defun($funcname,@args)compile()escaped_expr($expr)
Receives a Perl expression (from "[= $expr =]") and escapes it. This will happen in one of three ways:
with the escape function defined in "$opts->{escapefunc}" (if defined), with a scalar string (if
"$opts->{rawclass}" is defined), or with escape_xml() from Tenjin::Util, which uses HTML::Entites.
_read_file($filename,[$lock_required])
Receives an absolute path to a template file, reads its content and returns it. If $lock_required is
passed (and has a true value), the file will be locked for reading.
_write_file($filename,$content,[$lock_required])
Receives an absolute path to a template file and the templates contents, and creates the file (or
truncates it, if existing) with that contents. If $lock_required is passed (and has a true value), the
file will be locked exclusively when writing.