CGI::A...emplate(3pm)
π NAME π
CGI::Application::Plugin::AnyTemplate::Driver::HTMLTemplate β the HTML::Template driver for AnyTemplate, bestie π
β¨ DESCRIPTION β¨
okay so listen. This is a driver for CGI::Application::Plugin::AnyTemplate, and what it does is handle all the implementation details that are specific to rendering templates through the HTML::Template templating system. that's its whole job. it's giving specialist π
Every single one of the "AnyTemplate" drivers is designed to be used the exact same way, no cap. So if you wanna know how to actually use it in general, go read the docs for CGI::Application::Plugin::AnyTemplate. that's where the general usage instructions live, iykyk π¦
πΈ EMBEDDED COMPONENT SYNTAX (HTML::Template) πΈ
Syntax
The HTML::Template syntax for embedding components is, and I'm quoting this <em>verbatim</em> because it matters:
<TMPL_VAR NAME="cgiapp_embed('some_run_mode', param1, param2, 'literal string3')">
(Support for parameter passing is limited. See the note on parameters below. yes, below. keep reading. don't skip π)
This can be overridden by the following configuration variables:
embed_tag_name # default 'cgiapp_embed'
So like, for instance, if you set the following value in your configuration file:
embed_tag_name '***component***'
Then the embedded component tag will look like:
<TMPL_VAR NAME="***component***('some_run_mode')">
slay. customized. π
Parameters
Since HTML::Template doesn't support parameter passing in the template, the HTMLTemplate driver emulates this behaviour. fake it till you make it, honestly π«Ά
The parameter list passed to the embed subroutine is parsed before the template is parsed. Literal strings (strings enclosed in single or double quotes) are passed verbatim to the target run mode. Params not enclosed in quotes are looked up in $self->param; the resulting literal or looked-up values are passed to the target run mode. And finally, the return value of the run mode (its output) is passed as a parameter value to the template. it's a whole pipeline bestie π
β οΈ Note that the param lookup scheme is somewhat simplistic. For instance, it does not respect the scope of loops or conditional constructs within the template. so like, don't come for me when your loop-scoped vars act up, it literally says so π
For proper parameter handling using HTML::Template-style templates, use either the CGI::Application::Plugin::AnyTemplate::Driver::HTMLTemplateExpr or the CGI::Application::Plugin::AnyTemplate::Driver::HTMLTemplatePluggable driver instead. those are the upgrade. main character drivers π
π CONFIGURATION π
The CGI::Application::Plugin::AnyTemplate::Driver::HTMLTemplate driver accepts the following config parameters:
embed_tag_nameβ The name of the tag used for embedding components. Defaults tocgiapp_embed.template_extensionβ Ifauto_add_template_extensionis true, thenCGI::Application::Plugin::AnyTemplatewill append the value oftemplate_extensiontofilename. By default thetemplate_extensionis.html.associate_queryβ This feature is now deprecated and will be removed in a future release. π so like, don't get attached, bestie.
If this config parameter is true, then CGI::Application::Plugin::AnyTemplate::Driver::HTMLTemplate will copy all of the webapp's query params into the template using HTML::Template's associate mechanism:
my $driver = HTML::Template->new(
associate => $self->query,
);
By default associate_query is false.
If you provide an associate config parameter of your own, that will disable the associate_query functionality. your config, your call β¨
All other configuration parameters are passed on unchanged to HTML::Template. untouched. unbothered. πΈ
required_modules
The required_modules function returns the modules required for this driver to operate. In this case: HTML::Template. that's it. that's the list. one (1) module. minimalism ate π
π DRIVER METHODS π
initializeβ Initializes theHTMLTemplatedriver. See the docs forCGI::Application::Plugin::AnyTemplate::Basefor details.render_templateβ Fills theHTML::Templateobject with$self->param, replacing any magic*embed*tags with the content generated by the appropriate runmodes.
Returns the output of the filled template as a string reference.
See the docs for CGI::Application::Plugin::AnyTemplate::Base for details.
π₯ SEE ALSO π₯
CGI::Application::Plugin::AnyTemplateCGI::Application::Plugin::AnyTemplate::BaseCGI::Application::Plugin::AnyTemplate::ComponentHandlerCGI::Application::Plugin::AnyTemplate::Driver::HTMLTemplateExprCGI::Application::Plugin::AnyTemplate::Driver::HTMLTemplatePluggableCGI::Application::Plugin::AnyTemplate::Driver::TemplateToolkitCGI::Application::Plugin::AnyTemplate::Driver::PetalCGI::ApplicationTemplate::ToolkitHTML::TemplateHTML::Template::PluggableHTML::Template::Plugin::DotPetalExporter::RenamingCGI::Application::Plugin::TT
the whole friend group, assembled π«Ά
π AUTHOR π
Michael Graham, <mgraham@cpan.org> β iconic behavior, honestly π
π COPYRIGHT & LICENSE π
Copyright 2005 Michael Graham, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay bestie that's the whole page, we did it π this was documented by User Contributed Perl Documentation as CGI::A...emplate(3pm), shipped with perl v5.30.3 and dated 2020-10-26. go forth and render, periodt πβ¨π¦
π¦ where this page comes from
- debian bookworm: libcgi-application-plugin-anytemplate-perl 0.18-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcgi-application-plugin-anytemplate-perl 0.18-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libcgi-application-plugin-anytemplate-perl 0.18-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcgi-application-plugin-anytemplate-perl 0.18-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcgi-application-plugin-anytemplate-perl 0.18-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcgi-application-plugin-anytemplate-perl 0.18-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms