Cyclone3 Skin

Template Toolkit

From Cyclone3 Wiki

(Difference between revisions)
(Examples of usage)
(Examples of usage)
Line 35: Line 35:
<tt enabled="true" />
<tt enabled="true" />
</header>
</header>
 +
<entity id="main">
<entity id="main">
<![CDATA[
<![CDATA[
Line 43: Line 44:
[%END%]
[%END%]
</ul>
</ul>
 +
]]>
 +
</entity>
 +
</template>
</template>
</pre>
</pre>
[[Category:Labs]]
[[Category:Labs]]

Revision as of 07:15, 30 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

For Template Toolkit grammar check this documentation [1]

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>
    ]]>
    </entity>
    
</template>