This module is a subclass of
Template::TT3::Service
for adding a page
wrapper to a processed template. A page wrapper is a template containing
a reference to a content
variable. The wrapper template is processed
with the content
variable set to contain the output from the rest of
the service pipeline (e.g. the output generated from the main template plus
any other header, footers, etc., added by other services).
Used to specify the default template that should be used for a wrapper. 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 $wrapper = Template::TT3::Services->service( wrapper => 'site/wrapper.tt3', );
is syntactic sugar for:
my $wrapper = Template::TT3::Services->service( wrapper => { template => 'site/wrapper.tt3', }, );
This can be used to change the name of the service component. The default
name is wrapper
. If a wrapper
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', wrapper => 'my/wrapper.tt3', # over-ride default wrapper template );
If you want to have several different wrapper services in the same pipeline
then you should give them unique names. For example, you might set one to
site_wrapper
and the other to section_wrapper
. This allows you to
change the name of either independently.
$pipeline->( context => $context, input => 'example.tt3', site_wrapper => 'site/wrapper.tt3', section_wrapper => 'section/products/wrapper.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). A reference to a subroutine representing the rest of the pipeline is passed as the second argument.
The method looks in the environment for an item named wrapper
, or whatever
alternate
name
the service has been given (e.g. site_wrapper
,
section_wrapper
, etc). If the item isn't specified then it instead uses the
default wrapper
template
defined when the service is created. If that is
undefined or set to a false value (e.g. 0
or the empty string ''
) then
no wrapper is added.
Otherwise it executes the $pipeline
function to render the rest of the
service pipeline. It then processes the wrapper template with the content
variable set to contain the output from the $pipeline
function. It then
returns the output generated. If no wrapper template is specified then it
returns only the output from the $pipeline
function.
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 .