1 package SL::Template::Plugin::Base64;
8 use base qw(Template::Plugin);
13 $Template::Stash::SCALAR_OPS->{'encode_base64'} = \&_encode_base64;
14 $Template::Stash::SCALAR_OPS->{'decode_base64'} = \&_decode_base64;
17 my ($class, $context, $options) = @_;
19 $context->define_filter('encode_base64', \&_encode_base64);
20 $context->define_filter('decode_base64', \&_decode_base64);
21 return bless {}, $class;
25 return MIME::Base64::encode_base64(shift, '');
29 my ($self, $var) = @_;
30 return MIME::Base64::decode_base64(shift);
39 SL::Template::Plugin::Base64 - TT2 interface to base64 encoding/decoding
44 [% SELF.some_object.binary_stuff.encode_base64 -%]
45 [% SELF.some_object.binary_stuff FILTER encode_base64 -%]
49 The I<Base64> Template Toolkit plugin provides access to the Base64
50 routines from L<MIME::Base64>.
52 The following filters (and vmethods of the same name) are installed
53 into the current context:
57 =item C<encode_base64>
59 Returns the string encoded as Base64.
61 =item C<decode_base64>
63 Returns the Base64 string decoded back to binary.
67 As the filters are also available as vmethods the following are all
70 FILTER encode_base64; content; END;
71 content FILTER encode_base64;
72 content.encode_base64;
76 Moritz Bunkus E<lt>m.bunkus@linet-services.de<gt>