[Templates] Processing variables as templates
Gernot Homma
homma@cat.at
Thu, 12 Sep 2002 10:49:54 +0200
hello,
is there a possibility to evaluate a variable that contains some
tt2-directives inside a template ?
an example:
#
----------------------------------------------------------------------------
------
File test.tt2:
<html>
<body>
Here is some text
[% ANYDIRECTIVE x %]
</body>
</html>
#
----------------------------------------------------------------------------
------
File test_sub.tt2:
This is the text which should be included in the first template.
The templatetext comes from the variable x
#
----------------------------------------------------------------------------
------
File test.pl:
--- snip ---
my $x = qq~
[% INCLUDE test_sub.tt2 %]
~;
$tpl->process('test.tt2', { x => $x });
--- snip ---
#
----------------------------------------------------------------------------
------
The final output should looks like this:
#
----------------------------------------------------------------------------
------
<html>
<body>
Here is some text
This is the text which should be included in the first template.
The templatetext comes from the variable x
</body>
</html>
#
----------------------------------------------------------------------------
------
so in the variable x, which is passed to the template, i have some template
code, which should be evaluted at the [% ANYDIRECTIVE x %] - position, so
that the tt2-directives contained in x are processed, and so the file
test_sub.tt2 is included at the appropriate posititon.
is there any directive or already existing plugin, which performs this
operation or i have to do it on my own. (in case of that i need some glue
where to start;-)
hope that's clear what i try to do.
thanks in advance
gernot
Gernot Homma
Cyber-Atelier
Shuttleworthstrasse 4-8 / Objekt 50
fon: +43 1 272 92 51 2
fax: +43 1 272 92 51 9
mail: gernot.homma@cat.at