use Template3; Template3->render( input => 'hello.tt3', output => 'hello.html', );
This module is a subclass of
Template::TT3::Service
. It is usually the
final service component added to the end of a template service pipeline by the
Template::TT3::Engine::TT3
module. It redirects the output generated by
the preceding pipeline to the output target specified by the output
environment parameter. If this is undefined then the generated output is
returned.
TODO: Change the 'template' parameter to be something else... it's inherited from the base class because it's what most services use... but not all.
NOTE: The name of this parameter is confusing. It's not a template at all. It needs to be changed.
Used to specify the default template that should be used for output. It can
be specified as anything that the
Template::TT3::Hub
output()
method will accept, e.g. a
file name, text reference, subroutine reference, object with print()
method
or list reference.
template
is the default option for the service. Thus the following:
my $output = Template::TT3::Services->service( output => 'greeting.html', );
is syntactic sugar for:
my $output = Template::TT3::Services->service( output => { template => 'greeting.tt3', }, );
In most cases the output
won't be specified as a configuration option, but
provided as an environment parameter passed to the
render()
method (implemented by
Template::TT3::Engine::TT3
).
use Template3; print Template->render( input => 'greeting.tt3', output => 'greeting.html' );
This can be used to change the name of the service component. The default
name is output
. If an output
is specified in the environment passed
to the pipeline service function then it will be used in preference to the
default
template
.
$pipeline->( context => $context, input => 'greeting.tt3', output => 'greeting.html', );
This module implements the following methods in addition to those inherited from the Template::TT3::Service , Template::TT3::Base and Badger::Base base class modules.
This is the main service method. It is called automatically when the service is bound in a pipeline that is executed. A copy of the environment is passed as the first argument (a reference to a hash array).
The method looks in the environment for an item named output
, or whatever
alternate
name
the service has been given. If specified, it forwards the
output generated from the preceding service pipeline to the
Template::TT3::Hub
output()
method along
with the output parameter and any output options
(TODO: decide what this
should be called).
If no output
is specified in the environment then it simply returns
the generated output.
Andy Wardley http://wardley.org/
Copyright (C) 1996-2009 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.
This module inherits methods from the Template::TT3::Service , Template::TT3::Base and Badger::Base base classes.
Services are loaded and instantiated by the Template::TT3::Services factory module. This is accessible via the Template::TT3::Hub module. The Template::TT3::Engine::TT3 module uses the services module to construct a template processing pipeline.
Other similar services include Template::TT3::Service::Header , Template::TT3::Service::Footer , Template::TT3::Service::Layout , Template::TT3::Service::Before and Template::TT3::Service::After .