1#============================================================= -*-perl-*- 2# 3# Template 4# 5# DESCRIPTION 6# Module implementing a simple, user-oriented front-end to the Template 7# Toolkit. 8# 9# AUTHOR 10# Andy Wardley <abw@wardley.org> 11# 12# COPYRIGHT 13# Copyright (C) 1996-2012 Andy Wardley. All Rights Reserved. 14# 15# This module is free software; you can redistribute it and/or 16# modify it under the same terms as Perl itself. 17# 18#======================================================================== 19 20package Template; 21 22use strict; 23use warnings; 24use 5.006; 25use base 'Template::Base'; 26 27use Template::Config; 28use Template::Constants; 29use Template::Provider; 30use Template::Service; 31use File::Basename; 32use File::Path; 33use Scalar::Util qw(blessed); 34 35our $VERSION = '2.25'; 36our $ERROR = ''; 37our $DEBUG = 0; 38our $BINMODE = 0 unless defined $BINMODE; 39our $AUTOLOAD; 40 41# preload all modules if we're running under mod_perl 42Template::Config->preload() if $ENV{ MOD_PERL }; 43 44 45#------------------------------------------------------------------------ 46# process($input, \%replace, $output) 47# 48# Main entry point for the Template Toolkit. The Template module 49# delegates most of the processing effort to the underlying SERVICE 50# object, an instance of the Template::Service class. 51#------------------------------------------------------------------------ 52 53sub process { 54 my ($self, $template, $vars, $outstream, @opts) = @_; 55 my ($output, $error); 56 my $options = (@opts == 1) && ref($opts[0]) eq 'HASH' 57 ? shift(@opts) : { @opts }; 58 59 $options->{ binmode } = $BINMODE 60 unless defined $options->{ binmode }; 61 62 # we're using this for testing in t/output.t and t/filter.t so 63 # don't remove it if you don't want tests to fail... 64 $self->DEBUG("set binmode\n") if $DEBUG && $options->{ binmode }; 65 66 $output = $self->{ SERVICE }->process($template, $vars); 67 68 if (defined $output) { 69 $outstream ||= $self->{ OUTPUT }; 70 unless (ref $outstream) { 71 my $outpath = $self->{ OUTPUT_PATH }; 72 $outstream = "$outpath/$outstream" if $outpath; 73 } 74 75 # send processed template to output stream, checking for error 76 return ($self->error($error)) 77 if ($error = &_output($outstream, \$output, $options)); 78 79 return 1; 80 } 81 else { 82 return $self->error($self->{ SERVICE }->error); 83 } 84} 85 86 87#------------------------------------------------------------------------ 88# service() 89# 90# Returns a reference to the internal SERVICE object which handles 91# all requests for this Template object 92#------------------------------------------------------------------------ 93 94sub service { 95 my $self = shift; 96 return $self->{ SERVICE }; 97} 98 99 100#------------------------------------------------------------------------ 101# context() 102# 103# Returns a reference to the CONTEXT object within the SERVICE 104# object. 105#------------------------------------------------------------------------ 106 107sub context { 108 my $self = shift; 109 return $self->{ SERVICE }->{ CONTEXT }; 110} 111 112sub template { 113 shift->context->template(@_); 114} 115 116 117#======================================================================== 118# -- PRIVATE METHODS -- 119#======================================================================== 120 121#------------------------------------------------------------------------ 122# _init(\%config) 123#------------------------------------------------------------------------ 124sub _init { 125 my ($self, $config) = @_; 126 127 # convert any textual DEBUG args to numerical form 128 my $debug = $config->{ DEBUG }; 129 $config->{ DEBUG } = Template::Constants::debug_flags($self, $debug) 130 || return if defined $debug && $debug !~ /^\d+$/; 131 132 # prepare a namespace handler for any CONSTANTS definition 133 if (my $constants = $config->{ CONSTANTS }) { 134 my $ns = $config->{ NAMESPACE } ||= { }; 135 my $cns = $config->{ CONSTANTS_NAMESPACE } || 'constants'; 136 $constants = Template::Config->constants($constants) 137 || return $self->error(Template::Config->error); 138 $ns->{ $cns } = $constants; 139 } 140 141 $self->{ SERVICE } = $config->{ SERVICE } 142 || Template::Config->service($config) 143 || return $self->error(Template::Config->error); 144 145 $self->{ OUTPUT } = $config->{ OUTPUT } || \*STDOUT; 146 $self->{ OUTPUT_PATH } = $config->{ OUTPUT_PATH }; 147 148 return $self; 149} 150 151 152#------------------------------------------------------------------------ 153# _output($where, $text) 154#------------------------------------------------------------------------ 155 156sub _output { 157 my ($where, $textref, $options) = @_; 158 my $reftype; 159 my $error = 0; 160 161 # call a CODE reference 162 if (($reftype = ref($where)) eq 'CODE') { 163 &$where($$textref); 164 } 165 # print to a glob (such as \*STDOUT) 166 elsif ($reftype eq 'GLOB') { 167 print $where $$textref; 168 } 169 # append output to a SCALAR ref 170 elsif ($reftype eq 'SCALAR') { 171 $$where .= $$textref; 172 } 173 # push onto ARRAY ref 174 elsif ($reftype eq 'ARRAY') { 175 push @$where, $$textref; 176 } 177 # call the print() method on an object that implements the method 178 # (e.g. IO::Handle, Apache::Request, etc) 179 elsif (blessed($where) && $where->can('print')) { 180 $where->print($$textref); 181 } 182 # a simple string is taken as a filename 183 elsif (! $reftype) { 184 local *FP; 185 # make destination directory if it doesn't exist 186 my $dir = dirname($where); 187 eval { mkpath($dir) unless -d $dir; }; 188 if ($@) { 189 # strip file name and line number from error raised by die() 190 ($error = $@) =~ s/ at \S+ line \d+\n?$//; 191 } 192 elsif (open(FP, ">$where")) { 193 # binmode option can be 1 or a specific layer, e.g. :utf8 194 my $bm = $options->{ binmode }; 195 if ($bm && $bm eq 1) { 196 binmode FP; 197 } 198 elsif ($bm){ 199 binmode FP, $bm; 200 } 201 print FP $$textref; 202 close FP; 203 } 204 else { 205 $error = "$where: $!"; 206 } 207 } 208 # give up, we've done our best 209 else { 210 $error = "output_handler() cannot determine target type ($where)\n"; 211 } 212 213 return $error; 214} 215 216 2171; 218 219__END__ 220 221=head1 NAME 222 223Template - Front-end module to the Template Toolkit 224 225=head1 SYNOPSIS 226 227 use Template; 228 229 # some useful options (see below for full list) 230 my $config = { 231 INCLUDE_PATH => '/search/path', # or list ref 232 INTERPOLATE => 1, # expand "$var" in plain text 233 POST_CHOMP => 1, # cleanup whitespace 234 PRE_PROCESS => 'header', # prefix each template 235 EVAL_PERL => 1, # evaluate Perl code blocks 236 }; 237 238 # create Template object 239 my $template = Template->new($config); 240 241 # define template variables for replacement 242 my $vars = { 243 var1 => $value, 244 var2 => \%hash, 245 var3 => \@list, 246 var4 => \&code, 247 var5 => $object, 248 }; 249 250 # specify input filename, or file handle, text reference, etc. 251 my $input = 'myfile.html'; 252 253 # process input template, substituting variables 254 $template->process($input, $vars) 255 || die $template->error(); 256 257=head1 DESCRIPTION 258 259This documentation describes the Template module which is the direct 260Perl interface into the Template Toolkit. It covers the use of the 261module and gives a brief summary of configuration options and template 262directives. Please see L<Template::Manual> for the complete reference 263manual which goes into much greater depth about the features and use 264of the Template Toolkit. The L<Template::Tutorial> is also available 265as an introductory guide to using the Template Toolkit. 266 267=head1 METHODS 268 269=head2 new(\%config) 270 271The C<new()> constructor method (implemented by the 272L<Template::Base|Template::Base#new()> base class) instantiates a new 273C<Template> object. A reference to a hash array of configuration items may be 274passed as a parameter. 275 276 my $tt = Template->new({ 277 INCLUDE_PATH => '/usr/local/templates', 278 EVAL_PERL => 1, 279 }) || die $Template::ERROR, "\n"; 280 281A reference to a new C<Template> object is returned, or undef on error. In the 282latter case, the error message can be retrieved by calling L<error()> as a 283class method or by examining the C<$Template::ERROR> package variable 284directly. 285 286 my $tt = Template->new(\%config) 287 || die Template->error(), "\n"; 288 289 my $tt = Template->new(\%config) 290 || die $Template::ERROR, "\n"; 291 292For convenience, configuration items may also be specified as a list 293of items instead of a hash array reference. These are automatically 294folded into a hash array by the constructor. 295 296 my $tt = Template->new(INCLUDE_PATH => '/tmp', POST_CHOMP => 1) 297 || die $Template::ERROR, "\n"; 298 299=head2 process($template, \%vars, $output, %options) 300 301The C<process()> method is called to process a template. The first parameter 302indicates the input template as one of: a filename relative to 303C<INCLUDE_PATH>, if defined; a reference to a text string containing the 304template text; or a file handle reference (e.g. C<IO::Handle> or sub-class) or 305C<GLOB> (e.g. C<\*STDIN>), from which the template can be read. A reference to 306a hash array may be passed as the second parameter, containing definitions of 307template variables. 308 309 # filename 310 $tt->process('welcome.tt2') 311 || die $tt->error(), "\n"; 312 313 # text reference 314 $text = "[% INCLUDE header %]\nHello world!\n[% INCLUDE footer %]"; 315 $tt->process(\$text) 316 || die $tt->error(), "\n"; 317 318 # file handle (GLOB) 319 $tt->process(\*DATA) 320 || die $tt->error(), "\n"; 321 322 __END__ 323 [% INCLUDE header %] 324 This is a template defined in the __END__ section which is 325 accessible via the DATA "file handle". 326 [% INCLUDE footer %] 327 328By default, the processed template output is printed to C<STDOUT>. The 329C<process()> method then returns C<1> to indicate success. A third parameter 330may be passed to the C<process()> method to specify a different output location. 331This value may be one of: a plain string indicating a filename which will be 332opened (relative to C<OUTPUT_PATH>, if defined) and the output written to; a file 333GLOB opened ready for output; a reference to a scalar (e.g. a text string) to 334which output/error is appended; a reference to a subroutine which is called, 335passing the output as a parameter; or any object reference which implements a 336C<print()> method (e.g. C<IO::Handle>, C<Apache::Request>, etc.) which will be called, 337passing the generated output as a parameter. 338 339Examples: 340 341 # output filename 342 $tt->process('welcome.tt2', $vars, 'welcome.html') 343 || die $tt->error(), "\n"; 344 345 # reference to output subroutine 346 sub myout { 347 my $output = shift; 348 ... 349 } 350 $tt->process('welcome.tt2', $vars, \&myout) 351 || die $tt->error(), "\n"; 352 353 # reference to output text string 354 my $output = ''; 355 $tt->process('welcome.tt2', $vars, \$output) 356 || die $tt->error(), "\n"; 357 358 print "output: $output\n"; 359 360In an Apache/mod_perl handler: 361 362 sub handler { 363 my $req = shift; 364 365 # ...your code here... 366 367 # direct output to Apache::Request via $req->print($output) 368 $tt->process($file, $vars, $req) || do { 369 $req->log_reason($tt->error()); 370 return SERVER_ERROR; 371 }; 372 return OK; 373 } 374 375After the optional third output argument can come an optional 376reference to a hash or a list of C<(name, value)> pairs providing further 377options for the output. The only option currently supported is 378C<binmode> which, when set to any true value will ensure that files 379created (but not any existing file handles passed) will be set to 380binary mode. 381 382 # either: hash reference of options 383 $tt->process($infile, $vars, $outfile, { binmode => 1 }) 384 || die $tt->error(), "\n"; 385 386 # or: list of name, value pairs 387 $tt->process($infile, $vars, $outfile, binmode => 1) 388 || die $tt->error(), "\n"; 389 390Alternately, the C<binmode> argument can specify a particular IO layer such 391as C<:utf8>. 392 393 $tt->process($infile, $vars, $outfile, binmode => ':utf8') 394 || die $tt->error(), "\n"; 395 396The C<OUTPUT> configuration item can be used to specify a default output 397location other than C<\*STDOUT>. The C<OUTPUT_PATH> specifies a directory 398which should be prefixed to all output locations specified as filenames. 399 400 my $tt = Template->new({ 401 OUTPUT => sub { ... }, # default 402 OUTPUT_PATH => '/tmp', 403 ... 404 }) || die Template->error(), "\n"; 405 406 # use default OUTPUT (sub is called) 407 $tt->process('welcome.tt2', $vars) 408 || die $tt->error(), "\n"; 409 410 # write file to '/tmp/welcome.html' 411 $tt->process('welcome.tt2', $vars, 'welcome.html') 412 || die $tt->error(), "\n"; 413 414The C<process()> method returns C<1> on success or C<undef> on error. The 415error message generated in the latter case can be retrieved by calling the 416L<error()> method. See also L<CONFIGURATION SUMMARY> which describes how error 417handling may be further customised. 418 419=head2 error() 420 421When called as a class method, it returns the value of the C<$ERROR> package 422variable. Thus, the following are equivalent. 423 424 my $tt = Template->new() 425 || die Template->error(), "\n"; 426 427 my $tt = Template->new() 428 || die $Template::ERROR, "\n"; 429 430When called as an object method, it returns the value of the internal 431C<_ERROR> variable, as set by an error condition in a previous call to 432process(). 433 434 $tt->process('welcome.tt2') 435 || die $tt->error(), "\n"; 436 437Errors are represented in the Template Toolkit by objects of the 438L<Template::Exception> class. If the L<process()> method returns a false value 439then the C<error()> method can be called to return an object of this class. 440The L<type()|Template::Exception#type()> and 441L<info()|Template::Exception#info()> methods can called on the object to 442retrieve the error type and information string, respectively. The 443L<as_string()|Template::Exception#as_string()> 444method can be called to return a string of the form C<$type - $info>. This 445method is also overloaded onto the stringification operator allowing the 446object reference itself to be printed to return the formatted error string. 447 448 $tt->process('somefile') || do { 449 my $error = $tt->error(); 450 print "error type: ", $error->type(), "\n"; 451 print "error info: ", $error->info(), "\n"; 452 print $error, "\n"; 453 }; 454 455=head2 service() 456 457The C<Template> module delegates most of the effort of processing templates 458to an underlying L<Template::Service> object. This method returns a reference 459to that object. 460 461=head2 context() 462 463The L<Template::Service> module uses a core L<Template::Context> object for 464runtime processing of templates. This method returns a reference to 465that object and is equivalent to C<< $template-E<gt>service-E<gt>context() >>. 466 467=head2 template($name) 468 469This method is a simple wrapper around the L<Template::Context> method of the 470same name. It returns a compiled template for the source provided as an 471argument. 472 473=head1 CONFIGURATION SUMMARY 474 475The following list gives a short summary of each Template Toolkit 476configuration option. See L<Template::Manual::Config> for full details. 477 478=head2 Template Style and Parsing Options 479 480=head3 ENCODING 481 482Specifies the character encoding. 483 484=head3 START_TAG, END_TAG 485 486Define tokens that indicate start and end of directives 487(default: 'C<[%>' and 'C<%]>'). 488 489=head3 TAG_STYLE 490 491Set C<START_TAG> and C<END_TAG> according to a pre-defined style (default: 492'C<template>', as above). 493 494=head3 PRE_CHOMP, POST_CHOMP 495 496Removes whitespace before/after directives (default: 0/0). 497 498=head3 TRIM 499 500Remove leading and trailing whitespace from template output (default: 0). 501 502=head3 INTERPOLATE 503 504Interpolate variables embedded like C<$this> or C<${this}> (default: 0). 505 506=head3 ANYCASE 507 508Allow directive keywords in lower case (default: 0 - UPPER only). 509 510=head2 Template Files and Blocks 511 512=head3 INCLUDE_PATH 513 514One or more directories to search for templates. 515 516=head3 DELIMITER 517 518Delimiter for separating paths in C<INCLUDE_PATH> (default: 'C<:>'). 519 520=head3 ABSOLUTE 521 522Allow absolute file names, e.g. C</foo/bar.html> (default: 0). 523 524=head3 RELATIVE 525 526Allow relative filenames, e.g. C<../foo/bar.html> (default: 0). 527 528=head3 DEFAULT 529 530Default template to use when another not found. 531 532=head3 BLOCKS 533 534Hash array pre-defining template blocks. 535 536=head3 AUTO_RESET 537 538Enabled by default causing C<BLOCK> definitions to be reset each time a 539template is processed. Disable to allow C<BLOCK> definitions to persist. 540 541=head3 RECURSION 542 543Flag to permit recursion into templates (default: 0). 544 545=head2 Template Variables 546 547=head3 VARIABLES 548 549Hash array of variables and values to pre-define in the stash. 550 551=head2 Runtime Processing Options 552 553=head3 EVAL_PERL 554 555Flag to indicate if C<PERL>/C<RAWPERL> blocks should be processed (default: 0). 556 557=head3 PRE_PROCESS, POST_PROCESS 558 559Name of template(s) to process before/after main template. 560 561=head3 PROCESS 562 563Name of template(s) to process instead of main template. 564 565=head3 ERROR 566 567Name of error template or reference to hash array mapping error types to 568templates. 569 570=head3 OUTPUT 571 572Default output location or handler. 573 574=head3 OUTPUT_PATH 575 576Directory into which output files can be written. 577 578=head3 DEBUG 579 580Enable debugging messages. 581 582=head2 Caching and Compiling Options 583 584=head3 CACHE_SIZE 585 586Maximum number of compiled templates to cache in memory (default: 587undef - cache all) 588 589=head3 COMPILE_EXT 590 591Filename extension for compiled template files (default: undef - don't 592compile). 593 594=head3 COMPILE_DIR 595 596Root of directory in which compiled template files should be written 597(default: undef - don't compile). 598 599=head2 Plugins and Filters 600 601=head3 PLUGINS 602 603Reference to a hash array mapping plugin names to Perl packages. 604 605=head3 PLUGIN_BASE 606 607One or more base classes under which plugins may be found. 608 609=head3 LOAD_PERL 610 611Flag to indicate regular Perl modules should be loaded if a named plugin 612can't be found (default: 0). 613 614=head3 FILTERS 615 616Hash array mapping filter names to filter subroutines or factories. 617 618=head2 Customisation and Extension 619 620=head3 LOAD_TEMPLATES 621 622List of template providers. 623 624=head3 LOAD_PLUGINS 625 626List of plugin providers. 627 628=head3 LOAD_FILTERS 629 630List of filter providers. 631 632=head3 TOLERANT 633 634Set providers to tolerate errors as declinations (default: 0). 635 636=head3 SERVICE 637 638Reference to a custom service object (default: L<Template::Service>). 639 640=head3 CONTEXT 641 642Reference to a custom context object (default: L<Template::Context>). 643 644=head3 STASH 645 646Reference to a custom stash object (default: L<Template::Stash>). 647 648=head3 PARSER 649 650Reference to a custom parser object (default: L<Template::Parser>). 651 652=head3 GRAMMAR 653 654Reference to a custom grammar object (default: L<Template::Grammar>). 655 656=head1 DIRECTIVE SUMMARY 657 658The following list gives a short summary of each Template Toolkit directive. 659See L<Template::Manual::Directives> for full details. 660 661=head2 GET 662 663Evaluate and print a variable or value. 664 665 [% GET variable %] # 'GET' keyword is optional 666 [% variable %] 667 [% hash.key %] 668 [% list.n %] 669 [% code(args) %] 670 [% obj.meth(args) %] 671 [% "value: $var" %] 672 673=head2 CALL 674 675As per L<GET> but without printing result (e.g. call code) 676 677 [% CALL variable %] 678 679=head2 SET 680 681Assign a values to variables. 682 683 [% SET variable = value %] # 'SET' also optional 684 [% variable = other_variable 685 variable = 'literal text @ $100' 686 variable = "interpolated text: $var" 687 list = [ val, val, val, val, ... ] 688 list = [ val..val ] 689 hash = { var => val, var => val, ... } 690 %] 691 692=head2 DEFAULT 693 694Like L<SET>, but variables are only set if currently unset (i.e. have no 695true value). 696 697 [% DEFAULT variable = value %] 698 699=head2 INSERT 700 701Insert a file without any processing performed on the contents. 702 703 [% INSERT legalese.txt %] 704 705=head2 PROCESS 706 707Process another template file or block and insert the generated output. 708Any template L<BLOCK>s or variables defined or updated in the C<PROCESS>ed 709template will thereafter be defined in the calling template. 710 711 [% PROCESS template %] 712 [% PROCESS template var = val, ... %] 713 714=head2 INCLUDE 715 716Similar to C<PROCESS>, but using a local copy of the current variables. 717Any template C<BLOCK>s or variables defined in the C<INCLUDE>d template 718remain local to it. 719 720 [% INCLUDE template %] 721 [% INCLUDE template var = val, ... %] 722 723=head2 WRAPPER 724 725The content between the C<WRAPPER> and corresponding C<END> directives is first 726evaluated, with the output generated being stored in the C<content> variable. 727The named template is then process as per C<INCLUDE>. 728 729 [% WRAPPER layout %] 730 Some template markup [% blah %]... 731 [% END %] 732 733A simple F<layout> template might look something like this: 734 735 Your header here... 736 [% content %] 737 Your footer here... 738 739=head2 BLOCK 740 741Define a named template block for L<INCLUDE>, L<PROCESS> and L<WRAPPER> 742to use. 743 744 [% BLOCK hello %] 745 Hello World 746 [% END %] 747 748 [% INCLUDE hello %] 749 750=head2 FOREACH 751 752Repeat the enclosed C<FOREACH> ... C<END> block for each value in the list. 753 754 [% FOREACH variable IN [ val, val, val ] %] # either 755 [% FOREACH variable IN list %] # or 756 The variable is set to [% variable %] 757 [% END %] 758 759=head2 WHILE 760 761The block enclosed between C<WHILE> and C<END> block is processed while 762the specified condition is true. 763 764 [% WHILE condition %] 765 content 766 [% END %] 767 768=head2 IF / UNLESS / ELSIF / ELSE 769 770The enclosed block is processed if the condition is true / false. 771 772 [% IF condition %] 773 content 774 [% ELSIF condition %] 775 content 776 [% ELSE %] 777 content 778 [% END %] 779 780 [% UNLESS condition %] 781 content 782 [% # ELSIF/ELSE as per IF, above %] 783 content 784 [% END %] 785 786=head2 SWITCH / CASE 787 788Multi-way switch/case statement. 789 790 [% SWITCH variable %] 791 [% CASE val1 %] 792 content 793 [% CASE [ val2, val3 ] %] 794 content 795 [% CASE %] # or [% CASE DEFAULT %] 796 content 797 [% END %] 798 799=head2 MACRO 800 801Define a named macro. 802 803 [% MACRO name <directive> %] 804 [% MACRO name(arg1, arg2) <directive> %] 805 ... 806 [% name %] 807 [% name(val1, val2) %] 808 809=head2 FILTER 810 811Process enclosed C<FILTER> ... C<END> block then pipe through a filter. 812 813 [% FILTER name %] # either 814 [% FILTER name( params ) %] # or 815 [% FILTER alias = name( params ) %] # or 816 content 817 [% END %] 818 819=head2 USE 820 821Load a plugin module (see C<Template::<Manual::Plugins>), or any regular Perl 822module when the C<LOAD_PERL> option is set. 823 824 [% USE name %] # either 825 [% USE name( params ) %] # or 826 [% USE var = name( params ) %] # or 827 ... 828 [% name.method %] 829 [% var.method %] 830 831=head2 PERL / RAWPERL 832 833Evaluate enclosed blocks as Perl code (requires the C<EVAL_PERL> option to be 834set). 835 836 [% PERL %] 837 # perl code goes here 838 $stash->set('foo', 10); 839 print "set 'foo' to ", $stash->get('foo'), "\n"; 840 print $context->include('footer', { var => $val }); 841 [% END %] 842 843 [% RAWPERL %] 844 # raw perl code goes here, no magic but fast. 845 $output .= 'some output'; 846 [% END %] 847 848=head2 TRY / THROW / CATCH / FINAL 849 850Exception handling. 851 852 [% TRY %] 853 content 854 [% THROW type info %] 855 [% CATCH type %] 856 catch content 857 [% error.type %] [% error.info %] 858 [% CATCH %] # or [% CATCH DEFAULT %] 859 content 860 [% FINAL %] 861 this block is always processed 862 [% END %] 863 864=head2 NEXT 865 866Jump straight to the next item in a C<FOREACH> or C<WHILE> loop. 867 868 [% NEXT %] 869 870=head2 LAST 871 872Break out of C<FOREACH> or C<WHILE> loop. 873 874 [% LAST %] 875 876=head2 RETURN 877 878Stop processing current template and return to including templates. 879 880 [% RETURN %] 881 882=head2 STOP 883 884Stop processing all templates and return to caller. 885 886 [% STOP %] 887 888=head2 TAGS 889 890Define new tag style or characters (default: C<[%> C<%]>). 891 892 [% TAGS html %] 893 [% TAGS <!-- --> %] 894 895=head2 COMMENTS 896 897Ignored and deleted. 898 899 [% # this is a comment to the end of line 900 foo = 'bar' 901 %] 902 903 [%# placing the '#' immediately inside the directive 904 tag comments out the entire directive 905 %] 906 907=head1 SOURCE CODE REPOSITORY 908 909The source code for the Template Toolkit is held in a public git repository 910on Github: L<https://github.com/abw/Template2> 911 912=head1 AUTHOR 913 914Andy Wardley E<lt>abw@wardley.orgE<gt> L<http://wardley.org/> 915 916=head1 VERSION 917 918Template Toolkit version 2.24, released February 2012. 919 920=head1 COPYRIGHT 921 922Copyright (C) 1996-2012 Andy Wardley. All Rights Reserved. 923 924This module is free software; you can redistribute it and/or 925modify it under the same terms as Perl itself. 926 927=cut 928 929# Local Variables: 930# mode: perl 931# perl-indent-level: 4 932# indent-tabs-mode: nil 933# End: 934# 935# vim: expandtab shiftwidth=4: 936