Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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)];

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 contemplating the Monastery: (7)
As of 2016-10-25 23:31 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (330 votes). Check out past polls.