|
NAMEText::MicroMason::TextTemplate - Alternate Syntax like Text::TemplateSYNOPSISInstead of using this class directly, pass its name to be mixed in:use Text::MicroMason; my $mason = Text::MicroMason::Base->new( -TextTemplate ); Use the standard compile and execute methods to parse and evaluate templates: print $mason->compile( text=>$template )->( @%args ); print $mason->execute( text=>$template, @args ); Text::Template provides a syntax to mix Perl into a text template: { my $hour = (localtime)[2]; my $daypart = ( $hour > 11 ) ? 'afternoon' : 'morning'; '' } Good { $daypart }, { $name }! DESCRIPTIONThis mixin class overrides several methods to allow MicroMason to emulate the template syntax and some of the other features of Text::Template.Compatibility with Text::TemplateThis is not a drop-in replacement for Text::Template, as the Perl calling interface is quite different, but it should be able to process most existing templates without major changes.This should allow current Text::Template users to take advantage of MicroMason's one-time compilation feature, which in theory could be faster than Text::Template's repeated evals for each expression. (No benchmarking yet.) Contributed patches to more closely support the syntax of Text::Template documents would be welcomed by the author. Template SyntaxThe following elements are recognized by the TextTemplate lexer:
Argument PassingLike Text::Template, this package clobbers a target namespace to pass in template arguments as package variables. For example, if you pass in an argument list of "foo => 23", it will set the variable $foo in your package.The strict pragma is disabled to facilitate these variable references. Internally, this module inherits this functionality from the PassVariables mixin. If you are using the TextTemplate mixin, do not also specify the PassVariables mixin or it will be included twice. For more information, see Text::MicroMason::PassVariables. Supported Attributes
Private Methods
SEE ALSOThe interface being emulated is described in Text::Template.For an overview of this templating framework, see Text::MicroMason. This is a mixin class intended for use with Text::MicroMason::Base. For distribution, installation, support, copyright and license information, see Text::MicroMason::Docs::ReadMe.
Visit the GSP FreeBSD Man Page Interface. |