This module is a subclass of
Template::TT3::Service
. It is the initial
service component added to the start of a template service pipeline by the
Template::TT3::Engine::TT3
module. It fetches the input template
(identified as the input
item in the environment and processes it. The
output generated is returned.
Used to specify the default template that should be used for input. It can be specified as anything that the Template::TT3::Templates template() method will accept, e.g. a template name, text references, subroutine reference, etc.
template
is the default option for the service. Thus the following:
my $input = Template::TT3::Services->service( input => 'greeting.tt3', );
is syntactic sugar for:
my $input = Template::TT3::Services->service( input => { template => 'greeting.tt3', }, );
In most cases the input
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' );
This can be used to change the name of the service component. The default
name is input
. If an input
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 => 'example.tt3', );
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 input
, or whatever
alternate
name
the service has been given. It then fetches the template,
processes it and returns the output generated.
This service component is an input source and expects to be connected at
the start of a pipeline. Other components expect a reference to the source
component that precedes it and will throw an error via the no_source()
method if one isn't provided.
This module re-defines the no_source()
method to silently return undef
.
This allows it to be used at the start of a service pipeline.
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 .