[Templates] Need context information within dynamic filter
Olivier Salaün - CRU
olivier.salaun@cru.fr
Fri, 24 Nov 2006 15:35:18 +0100
This is a multi-part message in MIME format.
--------------020908080908010802080702
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hello,
I have written a custom dynamic filter ; its goal being
internationalization of templates. Now I need that filter to find out
about its calling template (I don't ask for the line number in the
template).
I found out that filters get a Template::Context object as their first
parameter. A few dump later I managed to get the calling template
filename via the component entry of the stash. Here is my code :
sub myCustomFilter {
my ($context, @arg) = @_;
my $stash = $context->stash();
my $component = $stash->get('component');
my $template_name = $component->{'name'};
...
}
I also need to find out the full path of the calling template.
How can I get it from the Template::Context object ?
Thanks.
--------------020908080908010802080702
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello,<br>
<br>
I have written a custom dynamic filter ; its goal being
internationalization of templates. Now I need that filter to find out
about its calling template (I don't ask for the line number in the
template).<br>
<br>
I found out that filters get a Template::Context object as their first
parameter. A few dump later I managed to get the calling template
filename via the component entry of the stash. Here is my code :<br>
<blockquote>sub myCustomFilter {<br>
my ($context, @arg) = @_;<br>
<br>
my $stash = $context->stash();<br>
my $component = $stash->get('component');<br>
my $template_name = $component->{'name'};<br>
...<br>
}<br>
</blockquote>
I also need to find out the full path of the calling template. <br>
How can I get it from the Template::Context object ?<br>
<br>
Thanks.<br>
</body>
</html>
--------------020908080908010802080702--