You are in Home page » Products » Opensource » CPAN » HTML::Template::Extension » Help on line |
![]() |
![]() |
|||
![]() |
![]() |
NAMEHTML::Template::Extension - Module support extension for HTML::Template
SYNOPSISuse HTML::Template::Extension; my $text = qq | Standard module emulation ========================= If all is ok you can read this here --> <TMPL_VAR NAME="test"> |; my $comp = new HTML::Template::Extension( scalarref => \$text, plugins=>["DO_NOTHING"], ); $comp->param('test' => "It works!!!"); print $comp->output; # OUTPUT: # # Standard module emulation # ========================= # If all is ok you can read this here --> It works!!! my $text = qq | SLASH_VAR plugin activation =========================== Look to see if SLASH_VAR plugin is active --> <TMPL_VAR NAME="test">NO</TMPL_VAR> |; $comp->plugin_add("SLASH_VAR"); $comp->scalarref(\$text); $comp->param('test' => "YES"); print $comp->output; # OUTPUT: # # SLASH_VAR plugin activation # =========================== # Look to see if SLASH_VAR plugin is active --> YES my $text = qq | <HTML><BODY> HEAD_BODY plugin activation with autoDeleteHeader enabled ========================================================= Look to see if SLASH_VAR plugin is active --> <TMPL_VAR NAME="test">NO</TMPL_VAR> If you don't see HTML and BODY tags then HEAD_BODY plugin is active. </BODY> </HTML> |; $comp->plugin_add("HEAD_BODY"); $comp->scalarref(\$text); $comp->autoDeleteHeader(1); print $comp->output; print "and the header is..." . $comp->header. "\n"; # OUTPUT: # # HEAD_BODY plugin activation with autoDeleteHeader enabled # ========================================================= # Look to see if SLASH_VAR plugin is active --> YES # If you don't see HTML and BODY tags then HEAD_BODY plugin is active. # and the header is... # <HTML><BODY> my $text = qq | DOC plugin activation ===================== Look to see if SLASH_VAR plugin is active --> <TMPL_VAR NAME="test">NO</TMPL_VAR> Look to see if DOC plugin is active --> <TMPL_DOC>DOC plugin is NOT active</TMPL_DOC> |; $comp->autoDeleteHeader(0); $comp->scalarref(\$text); $comp->plugin_add("DOC"); print $comp->output; # OUTPUT: # # DOC plugin activation # ===================== # Look to see if SLASH_VAR plugin is active --> YES # Look to see if DOC plugin is active --> print qq | CSTART plugin activation ======================== |; my $text = qq | Look to see if SLASH_VAR plugin is active --> <TMPL_VAR NAME="test">NO</TMPL_VAR> Look to see if DOC plugin is active --> <TMPL_DOC>DOC plugin is NOT active</TMPL_DOC> <TMPL_CSTART> If you see ONLY this line then CSTART plugin is active.</TMPL_CSTART> |; $comp->plugin_add("CSTART"); $comp->scalarref(\$text); print $comp->output . "\n"; # OUTPUT: # # CSTART plugin activation # ======================== # If you see ONLY this line then CSTART plugin is active. print qq | IF_TERN plugin activation ========================= |; my $text = qq | If all is ok you can read this here --> It's BAD |; $comp->plugin_add("IF_TERN"); $comp->scalarref(\$text); $comp->param('test' => 1); print $comp->output . "\n"; # OUTPUT: # # IF_TERN plugin activation # ========================= # If all is ok you can read this here --> It works!!!
DESCRIPTIONThis module extends HTML::Template to easily support methods and tags not implemented in parent module. Piece of code needed to add new tags syntax and new functionality are called plugins. All plugins can be dynamically loaded for supporing needed syntax and functionality. This module is a derivated class of HTML::Template base module and, like so, works exactly ad HTML::Template do. But, relative to original module, it differ from:
All dynamic plugins live in the HTML::Template::Extension namespace and you can built your own extension to support you prefered tags and functionality. A plugin named DO_NOTHING is present in this package and can be use like a skeleton to built your own plugin. DO_NOTHING, as name says, add nothing to standard HTML::Template::Extension but there are other plugins just available:
For more information about this plugins see relative pods file.
METHODSFor method also present in the SUPER class there are only described differens. for a complete description of this methods take a look to SUPER class HTML::Template.
output( 'as' => \%params)Return text present in filename file using %params hash to set TMPL_* parameters present in this template
|