Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Handling Encoding in Templates

by Rhandom (Curate)
on Nov 12, 2007 at 19:12 UTC ( #650347=note: print w/ replies, xml ) Need Help??

in reply to Handling Encoding in Templates

Thanks to the patches by Carl Franks, Template::Alloy has included the ENCODING parameter since version 1.008 (which was released several weeks ago).

This means that you can use ENCODING on both TT2 style templates, as well as on HTML::Template templates and Text::Tmpl templates since Template::Alloy supports them all.

The following example shows usage for setting the encoding - though it is only pulling from a code ref in this example, the encoding works properly when a filename is used rather than a string ref.
use strict; use warnings; use Template::Alloy; my $t = Template::Alloy->new(ENCODING => 'UTF-8'); my $in = "[% foo %]|BAR ¥"; my $foo = 'fü'; my $out = ''; $t->process(\$in, {foo => $foo}, \$out) || die $t->error; print "\$out: $out\n"; # Prints # $out: fü|BAR ¥

my @a=qw(random brilliant braindead); print $a[rand(@a)];
Comment on Re: Handling Encoding in Templates
Download Code
Replies are listed 'Best First'.
Re^2: Handling Encoding in Templates
by moritz (Cardinal) on Nov 12, 2007 at 19:56 UTC
    Great, it works like a charm. Thanks to you and Carl Franks!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://650347]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2016-05-28 07:26 GMT
Find Nodes?
    Voting Booth?