Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

template::alloy::compile(3pm) [debian man page]

Template::Alloy::Compile(3pm)				User Contributed Perl Documentation			     Template::Alloy::Compile(3pm)

NAME
Template::Alloy::Compile - Compile role - allows for compiling the AST to perl code DESCRIPTION
The Template::Alloy::Compile role allows for taking the AST returned by the Parse role, and translating it into a perl code document. This is in contrast Template::Alloy::Play which executes the AST directly. TODO
o Translate compile_RAWPERL to actually output rather than calling play_RAWPERL. ROLE METHODS
"compile_tree" Takes an AST returned by parse_tree and translates it into perl code using functions stored in the $DIRECTIVES hashref. A template that looked like the following: Foo [% GET foo %] [% GET bar %] Bar would parse to the following perl code: # Generated by Template::Alloy::Compile v1.001 on Thu Jun 7 12:58:33 2007 # From file /home/paul/bar.tt my $blocks = {}; my $meta = {}; my $code = sub { my ($self, $out_ref, $var) = @_; $$out_ref .= 'Foo'; # "GET" Line 2 char 2 (chars 6 to 15) $var = $self->play_expr(['foo', 0]); $$out_ref .= defined($var) ? $var : $self->undefined_get(['foo', 0]); # "GET" Line 3 char 2 (chars 22 to 31) $var = $self->play_expr(['bar', 0]); $$out_ref .= defined($var) ? $var : $self->undefined_get(['bar', 0]); $$out_ref .= 'Bar'; return 1; }; { blocks => $blocks, meta => $meta, code => $code, }; As you can see the output is quite a bit more complex than the AST, but under mod_perl conditions, the perl will run faster than playing the AST each time. "compile_expr" Takes an AST variable or expression and returns perl code that can lookup the variable. AUTHOR
Paul Seamons <paul at seamons dot com> LICENSE
This module may be distributed under the same terms as Perl itself. perl v5.10.1 2008-09-17 Template::Alloy::Compile(3pm)

Check Out this Related Man Page

Template::Namespace::Constants(3pm)			User Contributed Perl Documentation		       Template::Namespace::Constants(3pm)

NAME
Template::Namespace::Constants - Compile time constant folding SYNOPSIS
# easy way to define constants use Template; my $tt = Template->new({ CONSTANTS => { pi => 3.14, e => 2.718, }, }); # nitty-gritty, hands-dirty way use Template::Namespace::Constants; my $tt = Template->new({ NAMESPACE => { constants => Template::Namespace::Constants->new({ pi => 3.14, e => 2.718, }, }, }); DESCRIPTION
The "Template::Namespace::Constants" module implements a namespace handler which is plugged into the "Template::Directive" compiler module. This then performs compile time constant folding of variables in a particular namespace. METHODS
new(\%constants) The new() constructor method creates and returns a reference to a new Template::Namespace::Constants object. This creates an internal stash to store the constant variable definitions passed as arguments. my $handler = Template::Namespace::Constants->new({ pi => 3.14, e => 2.718, }); ident(@ident) Method called to resolve a variable identifier into a compiled form. In this case, the method fetches the corresponding constant value from its internal stash and returns it. AUTHOR
Andy Wardley <abw@wardley.org> <http://wardley.org/> COPYRIGHT
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Directive perl v5.14.2 2011-12-20 Template::Namespace::Constants(3pm)
Man Page