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.24'; 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 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 the CONTEXT object withint 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 START_TAG, END_TAG 481 482Define tokens that indicate start and end of directives 483(default: 'C<[%>' and 'C<%]>'). 484 485=head3 TAG_STYLE 486 487Set C<START_TAG> and C<END_TAG> according to a pre-defined style (default: 488'C<template>', as above). 489 490=head3 PRE_CHOMP, POST_CHOMP 491 492Removes whitespace before/after directives (default: 0/0). 493 494=head3 TRIM 495 496Remove leading and trailing whitespace from template output (default: 0). 497 498=head3 INTERPOLATE 499 500Interpolate variables embedded like C<$this> or C<${this}> (default: 0). 501 502=head3 ANYCASE 503 504Allow directive keywords in lower case (default: 0 - UPPER only). 505 506=head2 Template Files and Blocks 507 508=head3 INCLUDE_PATH 509 510One or more directories to search for templates. 511 512=head3 DELIMITER 513 514Delimiter for separating paths in C<INCLUDE_PATH> (default: 'C<:>'). 515 516=head3 ABSOLUTE 517 518Allow absolute file names, e.g. C</foo/bar.html> (default: 0). 519 520=head3 RELATIVE 521 522Allow relative filenames, e.g. C<../foo/bar.html> (default: 0). 523 524=head3 DEFAULT 525 526Default template to use when another not found. 527 528=head3 BLOCKS 529 530Hash array pre-defining template blocks. 531 532=head3 AUTO_RESET 533 534Enabled by default causing C<BLOCK> definitions to be reset each time a 535template is processed. Disable to allow C<BLOCK> definitions to persist. 536 537=head3 RECURSION 538 539Flag to permit recursion into templates (default: 0). 540 541=head2 Template Variables 542 543=head3 VARIABLES 544 545Hash array of variables and values to pre-define in the stash. 546 547=head2 Runtime Processing Options 548 549=head3 EVAL_PERL 550 551Flag to indicate if C<PERL>/C<RAWPERL> blocks should be processed (default: 0). 552 553=head3 PRE_PROCESS, POST_PROCESS 554 555Name of template(s) to process before/after main template. 556 557=head3 PROCESS 558 559Name of template(s) to process instead of main template. 560 561=head3 ERROR 562 563Name of error template or reference to hash array mapping error types to 564templates. 565 566=head3 OUTPUT 567 568Default output location or handler. 569 570=head3 OUTPUT_PATH 571 572Directory into which output files can be written. 573 574=head3 DEBUG 575 576Enable debugging messages. 577 578=head2 Caching and Compiling Options 579 580=head3 CACHE_SIZE 581 582Maximum number of compiled templates to cache in memory (default: 583undef - cache all) 584 585=head3 COMPILE_EXT 586 587Filename extension for compiled template files (default: undef - don't 588compile). 589 590=head3 COMPILE_DIR 591 592Root of directory in which compiled template files should be written 593(default: undef - don't compile). 594 595=head2 Plugins and Filters 596 597=head3 PLUGINS 598 599Reference to a hash array mapping plugin names to Perl packages. 600 601=head3 PLUGIN_BASE 602 603One or more base classes under which plugins may be found. 604 605=head3 LOAD_PERL 606 607Flag to indicate regular Perl modules should be loaded if a named plugin 608can't be found (default: 0). 609 610=head3 FILTERS 611 612Hash array mapping filter names to filter subroutines or factories. 613 614=head2 Customisation and Extension 615 616=head3 LOAD_TEMPLATES 617 618List of template providers. 619 620=head3 LOAD_PLUGINS 621 622List of plugin providers. 623 624=head3 LOAD_FILTERS 625 626List of filter providers. 627 628=head3 TOLERANT 629 630Set providers to tolerate errors as declinations (default: 0). 631 632=head3 SERVICE 633 634Reference to a custom service object (default: L<Template::Service>). 635 636=head3 CONTEXT 637 638Reference to a custom context object (default: L<Template::Context>). 639 640=head3 STASH 641 642Reference to a custom stash object (default: L<Template::Stash>). 643 644=head3 PARSER 645 646Reference to a custom parser object (default: L<Template::Parser>). 647 648=head3 GRAMMAR 649 650Reference to a custom grammar object (default: L<Template::Grammar>). 651 652=head1 DIRECTIVE SUMMARY 653 654The following list gives a short summary of each Template Toolkit directive. 655See L<Template::Manual::Directives> for full details. 656 657=head2 GET 658 659Evaluate and print a variable or value. 660 661 [% GET variable %] # 'GET' keyword is optional 662 [% variable %] 663 [% hash.key %] 664 [% list.n %] 665 [% code(args) %] 666 [% obj.meth(args) %] 667 [% "value: $var" %] 668 669=head2 CALL 670 671As per L<GET> but without printing result (e.g. call code) 672 673 [% CALL variable %] 674 675=head2 SET 676 677Assign a values to variables. 678 679 [% SET variable = value %] # 'SET' also optional 680 [% variable = other_variable 681 variable = 'literal text @ $100' 682 variable = "interpolated text: $var" 683 list = [ val, val, val, val, ... ] 684 list = [ val..val ] 685 hash = { var => val, var => val, ... } 686 %] 687 688=head2 DEFAULT 689 690Like L<SET>, but variables are only set if currently unset (i.e. have no 691true value). 692 693 [% DEFAULT variable = value %] 694 695=head2 INSERT 696 697Insert a file without any processing performed on the contents. 698 699 [% INSERT legalese.txt %] 700 701=head2 PROCESS 702 703Process another template file or block and insert the generated output. 704Any template L<BLOCK>s or variables defined or updated in the C<PROCESS>ed 705template will thereafter be defined in the calling template. 706 707 [% PROCESS template %] 708 [% PROCESS template var = val, ... %] 709 710=head2 INCLUDE 711 712Similar to C<PROCESS>, but using a local copy of the current variables. 713Any template C<BLOCK>s or variables defined in the C<INCLUDE>d template 714remain local to it. 715 716 [% INCLUDE template %] 717 [% INCLUDE template var = val, ... %] 718 719=head2 WRAPPER 720 721The content between the C<WRAPPER> and correspondng C<END> directives is first 722evaluated, with the output generated being stored in the C<content> variable. 723The named template is then process as per C<INCLUDE>. 724 725 [% WRAPPER layout %] 726 Some template markup [% blah %]... 727 [% END %] 728 729A simple F<layout> template might look something like this: 730 731 Your header here... 732 [% content %] 733 Your footer here... 734 735=head2 BLOCK 736 737Define a named template block for L<INCLUDE>, L<PROCESS> and L<WRAPPER> 738to use. 739 740 [% BLOCK hello %] 741 Hello World 742 [% END %] 743 744 [% INCLUDE hello %] 745 746=head2 FOREACH 747 748Repeat the enclosed C<FOREACH> ... C<END> block for each value in the list. 749 750 [% FOREACH variable IN [ val, val, val ] %] # either 751 [% FOREACH variable IN list %] # or 752 The variable is set to [% variable %] 753 [% END %] 754 755=head2 WHILE 756 757The block enclosed between C<WHILE> and C<END> block is processed while 758the specified condition is true. 759 760 [% WHILE condition %] 761 content 762 [% END %] 763 764=head2 IF / UNLESS / ELSIF / ELSE 765 766The enclosed block is processed if the condition is true / false. 767 768 [% IF condition %] 769 content 770 [% ELSIF condition %] 771 content 772 [% ELSE %] 773 content 774 [% END %] 775 776 [% UNLESS condition %] 777 content 778 [% # ELSIF/ELSE as per IF, above %] 779 content 780 [% END %] 781 782=head2 SWITCH / CASE 783 784Multi-way switch/case statement. 785 786 [% SWITCH variable %] 787 [% CASE val1 %] 788 content 789 [% CASE [ val2, val3 ] %] 790 content 791 [% CASE %] # or [% CASE DEFAULT %] 792 content 793 [% END %] 794 795=head2 MACRO 796 797Define a named macro. 798 799 [% MACRO name <directive> %] 800 [% MACRO name(arg1, arg2) <directive> %] 801 ... 802 [% name %] 803 [% name(val1, val2) %] 804 805=head2 FILTER 806 807Process enclosed C<FILTER> ... C<END> block then pipe through a filter. 808 809 [% FILTER name %] # either 810 [% FILTER name( params ) %] # or 811 [% FILTER alias = name( params ) %] # or 812 content 813 [% END %] 814 815=head2 USE 816 817Load a plugin module (see C<Template::<Manual::Plugins>), or any regular Perl 818module when the C<LOAD_PERL> option is set. 819 820 [% USE name %] # either 821 [% USE name( params ) %] # or 822 [% USE var = name( params ) %] # or 823 ... 824 [% name.method %] 825 [% var.method %] 826 827=head2 PERL / RAWPERL 828 829Evaluate enclosed blocks as Perl code (requires the C<EVAL_PERL> option to be 830set). 831 832 [% PERL %] 833 # perl code goes here 834 $stash->set('foo', 10); 835 print "set 'foo' to ", $stash->get('foo'), "\n"; 836 print $context->include('footer', { var => $val }); 837 [% END %] 838 839 [% RAWPERL %] 840 # raw perl code goes here, no magic but fast. 841 $output .= 'some output'; 842 [% END %] 843 844=head2 TRY / THROW / CATCH / FINAL 845 846Exception handling. 847 848 [% TRY %] 849 content 850 [% THROW type info %] 851 [% CATCH type %] 852 catch content 853 [% error.type %] [% error.info %] 854 [% CATCH %] # or [% CATCH DEFAULT %] 855 content 856 [% FINAL %] 857 this block is always processed 858 [% END %] 859 860=head2 NEXT 861 862Jump straight to the next item in a C<FOREACH> or C<WHILE> loop. 863 864 [% NEXT %] 865 866=head2 LAST 867 868Break out of C<FOREACH> or C<WHILE> loop. 869 870 [% LAST %] 871 872=head2 RETURN 873 874Stop processing current template and return to including templates. 875 876 [% RETURN %] 877 878=head2 STOP 879 880Stop processing all templates and return to caller. 881 882 [% STOP %] 883 884=head2 TAGS 885 886Define new tag style or characters (default: C<[%> C<%]>). 887 888 [% TAGS html %] 889 [% TAGS <!-- --> %] 890 891=head2 COMMENTS 892 893Ignored and deleted. 894 895 [% # this is a comment to the end of line 896 foo = 'bar' 897 %] 898 899 [%# placing the '#' immediately inside the directive 900 tag comments out the entire directive 901 %] 902 903=head1 SOURCE CODE REPOSITORY 904 905The source code for the Template Toolkit is held in a public git repository 906on Github: L<https://github.com/abw/Template2> 907 908=head1 AUTHOR 909 910Andy Wardley E<lt>abw@wardley.orgE<gt> L<http://wardley.org/> 911 912=head1 VERSION 913 914Template Toolkit version 2.23, released January 2012. 915 916=head1 COPYRIGHT 917 918Copyright (C) 1996-2012 Andy Wardley. All Rights Reserved. 919 920This module is free software; you can redistribute it and/or 921modify it under the same terms as Perl itself. 922 923=cut 924 925# Local Variables: 926# mode: perl 927# perl-indent-level: 4 928# indent-tabs-mode: nil 929# End: 930# 931# vim: expandtab shiftwidth=4: 932