view release on metacpan or search on metacpan
your application from one templating system to another.
Embedded Components
In addition to template abstraction, "AnyTemplate" also provides a
*embedded component mechanism*. For instance, you might include a
*header* component at the top of every page and a *footer* component at
the bottom of every page.
These components are actually full CGI::Application run modes, and can
do anything normal run mode can do, including processing form parameters
and filling in their own templates. See below under "EMBEDDED
COMPONENTS" for details.
Multiple Named Template Configurations
You can set up multiple named template configurations and select between
them at run time.
sub cgiapp_init {
my $self = shift;
# Can't use Template::Toolkit any more -
You can also supply names and values to the template at this stage:
return $template->output('name' => 'value', 'name2' => 'value2');
If "return_references" option is set to true, then the return value of
"output" will be a reference to a string. If the "return_references"
option is false, then a copy of the string will be returned. By default
"return_references" is true.
When you call the "output" method, any components embedded in the
template are run. See "EMBEDDED COMPONENTS", below.
PRE- AND POST- PROCESS
There are several ways to customize the template process. You can modify
the template parameters before the template is filled, and you can
modify the output of the template after it has been filled.
Multiple applications and plugins can hook into the template process
pipeline, each making changes to the template input and output.
For instance, it will be possible to make a general-purpose
template is processed, and will be passed both a reference to the
template object and a reference to the output generated by the template.
This allows you to modify the output of the template:
sub my_tmpl_post_process {
my ($self, $template, $output_ref) = @_;
$$output_ref =~ s/foo/bar/;
}
EMBEDDED COMPONENTS
Introduction
"CGI::Application::Plugin::AnyTemplate" allows you to include
application components within your templates.
For instance, you might include a *header* component a the top of every
page and a *footer* component at the bottom of every page.
These componenets are actually first-class run modes. When the template
engine finds a special tag marking an embedded component, it passes
control to the run mode of that name. That run mode can then do whatever
lib/CGI/Application/Plugin/AnyTemplate.pm view on Meta::CPAN
=head2 Embedded Components
In addition to template abstraction, C<AnyTemplate> also provides a
I<embedded component mechanism>. For instance, you might include a
I<header> component at the top of every page and a I<footer> component
at the bottom of every page.
These components are actually full L<CGI::Application> run modes, and
can do anything normal run mode can do, including processing form
parameters and filling in their own templates. See
below under L<"EMBEDDED COMPONENTS"> for details.
=head2 Multiple Named Template Configurations
You can set up multiple named template configurations and select between
them at run time.
sub cgiapp_init {
my $self = shift;
# Can't use Template::Toolkit any more -
lib/CGI/Application/Plugin/AnyTemplate.pm view on Meta::CPAN
You can also supply names and values to the template at this stage:
return $template->output('name' => 'value', 'name2' => 'value2');
If C<return_references> option is set to true, then the return value
of C<output> will be a reference to a string. If the
C<return_references> option is false, then a copy of the string will be
returned. By default C<return_references> is true.
When you call the C<output> method, any components embedded in the
template are run. See L<"EMBEDDED COMPONENTS">, below.
=head1 PRE- AND POST- PROCESS
There are several ways to customize the template process. You can
modify the template parameters before the template is filled, and you
can modify the output of the template after it has been filled.
Multiple applications and plugins can hook into the template process
pipeline, each making changes to the template input and output.
lib/CGI/Application/Plugin/AnyTemplate.pm view on Meta::CPAN
This allows you to modify the output of the template:
sub my_tmpl_post_process {
my ($self, $template, $output_ref) = @_;
$$output_ref =~ s/foo/bar/;
}
=head1 EMBEDDED COMPONENTS
=head2 Introduction
C<CGI::Application::Plugin::AnyTemplate> allows you to include application
components within your templates.
For instance, you might include a I<header> component a the top of every
page and a I<footer> component at the bottom of every page.
These componenets are actually first-class run modes. When the template
lib/CGI/Application/Plugin/AnyTemplate/Base.pm view on Meta::CPAN
sub my_tmpl_post_process {
my ($self, $template, $output_ref) = @_;
$$output_ref =~ s/foo/bar/;
}
When you call the C<output> method, any components embedded in the
template are run. See C<EMBEDDED COMPONENTS>, below.
=cut
# calling forms:
# $template->output;
# $template->output('file.html', \%params);
# $template->output(\%params)
#
# $template->fill;
# $template->fill('file.html', \%params);
lib/CGI/Application/Plugin/AnyTemplate/Driver/HTMLTemplate.pm view on Meta::CPAN
=head1 DESCRIPTION
This is a driver for L<CGI::Application::Plugin::AnyTemplate>, which
provides the implementation details specific to rendering templates via
the L<HTML::Template> templating system.
All C<AnyTemplate> drivers are designed to be used the same way. For
general usage instructions, see the documentation of
L<CGI::Application::Plugin::AnyTemplate>.
=head1 EMBEDDED COMPONENT SYNTAX (HTML::Template)
=head2 Syntax
The L<HTML::Template> syntax for embedding components is:
<TMPL_VAR NAME="cgiapp_embed('some_run_mode', param1, param2, 'literal string3')">
I<(Support for parameter passing is limited. See the note on paramters below.)>
This can be overridden by the following configuration variables:
lib/CGI/Application/Plugin/AnyTemplate/Driver/HTMLTemplateExpr.pm view on Meta::CPAN
=head1 DESCRIPTION
This is a driver for L<CGI::Application::Plugin::AnyTemplate>, which
provides the implementation details specific to rendering templates via
the L<HTML::Template::Expr> templating system.
All C<AnyTemplate> drivers are designed to be used the same way. For
general usage instructions, see the documentation of
L<CGI::Application::Plugin::AnyTemplate>.
=head1 EMBEDDED COMPONENT SYNTAX (HTML::Template::Expr)
=head2 Syntax
The L<HTML::Template::Expr> syntax for embedding components is:
<TMPL_VAR EXPR="CGIAPP_embed('some_run_mode', param1, param2, 'literal string3')">
This can be overridden by the following configuration variables:
embed_tag_name # default 'CGIAPP_embed'
lib/CGI/Application/Plugin/AnyTemplate/Driver/HTMLTemplatePluggable.pm view on Meta::CPAN
=head1 DESCRIPTION
This is a driver for L<CGI::Application::Plugin::AnyTemplate>, which
provides the implementation details specific to rendering templates via
the L<HTML::Template::Pluggable> templating system.
All C<AnyTemplate> drivers are designed to be used the same way. For
general usage instructions, see the documentation of
L<CGI::Application::Plugin::AnyTemplate>.
=head1 EMBEDDED COMPONENT SYNTAX (HTML::Template::Pluggable)
=head2 Syntax
The L<HTML::Template::Pluggable> syntax for embedding components is:
<TMPL_VAR NAME="cgiapp.embed('some_run_mode', param1, param2, 'literal string3')">
This can be overridden by the following configuration variables:
embed_tag_name # default 'cgiapp'
lib/CGI/Application/Plugin/AnyTemplate/Driver/Petal.pm view on Meta::CPAN
=head1 DESCRIPTION
This is a driver for L<CGI::Application::Plugin::AnyTemplate>, which
provides the implementation details specific to rendering templates via
the L<Petal> templating system.
All C<AnyTemplate> drivers are designed to be used the same way. For
general usage instructions, see the documentation of
L<CGI::Application::Plugin::AnyTemplate>.
=head1 EMBEDDED COMPONENT SYNTAX (Petal)
B<Note that for embedding component to work properly in Petal, you need to enclose>
B<the contents of the included file in tags, such as C<< <span> >> tags.>
<span>
var: <span petal:replace="var"></span>
</span>
The C<Petal> syntax for embedding components is:
lib/CGI/Application/Plugin/AnyTemplate/Driver/TemplateToolkit.pm view on Meta::CPAN
=head1 DESCRIPTION
This is a driver for L<CGI::Application::Plugin::AnyTemplate>, which
provides the implementation details specific to rendering templates via
the L<Template::Toolkit|Template> templating system.
All C<AnyTemplate> drivers are designed to be used the same way. For
general usage instructions, see the documentation of
L<CGI::Application::Plugin::AnyTemplate>.
=head1 EMBEDDED COMPONENT SYNTAX (Template::Toolkit)
The L<Template::Toolkit|Template> syntax for embedding components is:
[% CGIAPP.embed("some_run_mode", param1, param2, 'literal string3') %]
This can be overridden by the following configuration variables:
embed_tag_name # default 'CGIAPP'
For instance by setting the following values in your configuration file: