Cyclone3 Skin

Template Toolkit

From Cyclone3 Wiki

(Difference between revisions)

Rfordinal (Talk | contribs)
(New page: Template Toolkit is from commit r5950 (2011-09-07) integrated part of Cyclone3 Framework, special TOM::Template library and everyone can use it. == Examples of usage == Perl code <p...)
Next diff →

Revision as of 13:42, 12 September 2011

Template Toolkit is from commit r5950 (2011-09-07) integrated part of Cyclone3 Framework, special TOM::Template library and everyone can use it.

Examples of usage

Perl code

my $tpl=new TOM::Template(
   'level' => "auto",
   'name' => "test",
   'content-type' => "xhtml"
);

# fill test data
for (1..10)
{
   my %db0_line=(
      'name'=>"test string".$_
   );
   $tpl->variables_push(\%db0_line);
}

$tpl->process();
print $tpl->{'output'};

XML template (TOM::Template)

<?xml version="1.0" encoding="UTF-8"?>
<template>
   <header>
       <tt enabled="true" />
   </header>
   <entity id="main">
   <![CDATA[
       <h1>[%title%]</h1>
       <ul>
           [%FOREACH item IN items%]
           <li>name: [%item.name%]</li>
           [%END%]
       </ul>
</template>