<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Templater - Parse data inside a template.

SYNOPSIS
       #!/usr/bin/perl
       use Text::Templater;

       my $tpl = new Text::Templater($tagname); 
       #Default tagname is "tpl"

       $tpl-&gt;setSource($some_template_text);

       #Set the data source...
       $tpl-&gt;setData({                
          name =&gt; ['bob', undef, 'daniel'],
          color =&gt; ['red', 'green', 'blue'],
          });
       #Or use existing objects.
       $tpl-&gt;setData($cgi);           
       $tpl-&gt;setData($sth);

       print $tpl-&gt;parse();  #Get the result.

ABSTRACT
    The objective of the Templater object is to separate data manipulation
    from it's representation while keeping out logic as much as possible
    from the representation side.

DESCRIPTION
    Templater receive the template and the data to be binded in the
    template. Then using the parse method, it return the result.

    One tag and 5 properties are defined in a xmlish way to describe data in
    the template. Internaly regular expressions are used instead of a xml
    parser, so it can be used with any kind of text files. Still, you can
    also use it in your xml while keeping their well-formedness and valitiy
    of the document.

    &lt;tpl id="x" name="key" index="0" nullout="no" list="CONST:1,2,3..." /&gt;

  Tag properties
    id="unique"
          You can specify the id of an element to make late reference to it.
          This can be used for not breaking the well-formedness of a xml
          document. You could write &lt;tpl id="myvalue" name="nom" /&gt; 
          &lt;othertag value="#myvalue" /&gt; instead of 
          &lt;other-tag value="&lt;tpl name="nom" /&gt;" /&gt;. 
          Note that the second alternalive will work as well.

    name="name"
          You can bind a specific data value to a tag using it's hash key.
          A tag without a name does not make sense.
          In the synopsis; &lt;tpl name="color" /&gt; eqals red.

    index="num"
          Specify the index of the value to be binded.
          If not specified, the current iteration is taken.
          In the synopsis; &lt;tpl name="color" index="1" /&gt; eqals green.

    nullout="yes|no"
          If the binded value is undef or '', all the expression
          is discarded. no is taken by default. In the synopsis: 
          &lt;tpl name="name" nullout="yes"&gt;hi&lt;/tpl&gt; equals nothing.

    list="CONST:1,2,3,..."
          Defines a specific constant "CONST" into the tag inner source.
          The value of CONST will alternativly be 1,2,3,1,2,etc
          The backslash is used as a dummy quote character.
          But no, you can't \u or \b :-)

  Tag forms
    The templater tag can be written as: &lt;tpl /&gt; or &lt;tpl&gt;&lt;/tpl&gt;. The first
    form will replace the tag with the corresponding binded data. The second
    form will loop each value of the binded data; the concatenation of each
    result is used as the sole result.

  Methods
    new Creates a new Templater object. You can specify the tag name to be
        used in templates. No verification of the validity of name is made.

    setSource
        If a scalar is passed, it is set to be the template. The source of
        the object is returned.

    setData
        If a value is passed, it is set to be the data to bind. CGI and STH
        objects can be passed. The data of the object is returned.

    parse
        Takes the template and parse the data inside using the templater
        tags. The parsed template is returned.

CREDITS
    Mathieu Gagnon, (c) 2005

    This package is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

</pre></body></html>