Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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 meditating upon the Monastery: (6)
As of 2016-06-26 11:22 GMT
Find Nodes?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...

    Results (328 votes). Check out past polls.