1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">
<html>
<head>
<title>Template</title>
<link rel="stylesheet" type="text/css" href="../css/blue.css" title="Clear Blue">
<link rel="alternate stylesheet" type="text/css" href="../css/orange.css" title="Clear Orange">
<link rel="alternate stylesheet" type="text/css" href="../css/green.css" title="Clear Green">
<link rel="alternate stylesheet" type="text/css" href="../css/purple.css" title="Clear Purple">
<link rel="alternate stylesheet" type="text/css" href="../css/grey.css" title="Clear Grey">
<link rel="alternate stylesheet" type="text/css" href="../css/print.css" title="Print">
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="../css/ie6.css" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="../css/ie7.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="../css/print.css" media="print">
<script type="text/javascript" src="../js/tt2.js"></script>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="author" content="Andy Wardley">
</head>
<body id="body">
<div id="layout">
<div id="header">
<a href="../index.html" id="logo" alt="" title="Click for the Home Page"><span class="alt">TT2 Home Page</span></a>
<ul id="trail">
<li><a href="../modules/index.html">Modules</a></li>
<li class="last"><a href="../modules/Template.html">Template.pm</a></li>
</ul>
<div class="controls">
<a href="#" class="menu show" onclick="widescreen_off(); return false" title="Show Menu">
<span class="about">Click to view the menu. It's very nice.</span>
</a>
<a href="#" class="menu hide" onclick="widescreen_on(); return false" title="Hide Menu">
<span class="about">Click to hide the menu and go all widescreen!</span>
</a>
<div class="pager">
<span class="go back">Back<span class="about">I'd love to help you go back but I can't. I'm just a badger.</span></span>
<a href="../modules/index.html" title="Template::Modules" class="go up">Up<span class="about"><h4>Template::Modules</h4>Template Toolkit Modules</span></a>
<a href="../modules/Template/index.html" title="Template::* Modules" class="go next">Next<span class="about"><h4>Template::* Modules</h4></span></a>
</div>
</div>
<h1 class="headline">Template</h1>
<h2 class="subhead">Front-end module to the Template Toolkit</h1>
</div>
<div id="page">
<div id="sidebar">
<a href="../index.html" id="logo"></a>
<div id="menu">
<ul class="menu">
<li class="l0 first"><a href="../manual/index.html">Manual</a></li>
<li class="l0"><a href="../modules/index.html" class="warm">Modules</a></li>
<li class="l1"><a href="../modules/Template.html" class="warm">Template.pm</a></li>
<li class="l1"><a href="../modules/Template/index.html">Template::*</a></li>
<li class="l0"><a href="../tools/index.html">Tools</a></li>
<li class="l0"><a href="../tutorial/index.html">Tutorial</a></li>
<li class="l0 last"><a href="../faq/index.html">FAQ</a></li>
</ul>
<div class="foot"></div>
</div>
</div>
<div id="content">
<div class="section">
<div class="head">
<h1 id="contents" onclick="switch_section(this)" title="Click title to show/hide section content.">Contents</h1>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<ul class="toc">
<li class=""><a href="#SYNOPSIS">SYNOPSIS</a></li>
<li class=""><a href="#DESCRIPTION">DESCRIPTION</a></li>
<li class=""><a href="#METHODS">METHODS</a></li>
<li class="sub"><a href="#method_new">new(\%config)</a></li>
<li class="sub"><a href="#method_process">process($template, \%vars, $output, %options)</a></li>
<li class="sub"><a href="#method_error">error()</a></li>
<li class="sub"><a href="#method_service">service()</a></li>
<li class="sub"><a href="#method_context">context()</a></li>
<li class="sub"><a href="#method_template">template($name)</a></li>
<li class=""><a href="#CONFIGURATION_SUMMARY">CONFIGURATION SUMMARY</a></li>
<li class="sub"><a href="#section_Template_Style_and_Parsing_Options">Template Style and Parsing Options</a></li>
<li class="subsub"><a href="#section_START_TAG_END_TAG">START_TAG, END_TAG</a></li>
<li class="subsub"><a href="#section_TAG_STYLE">TAG_STYLE</a></li>
<li class="subsub"><a href="#section_PRE_CHOMP_POST_CHOMP">PRE_CHOMP, POST_CHOMP</a></li>
<li class="subsub"><a href="#section_TRIM">TRIM</a></li>
<li class="subsub"><a href="#section_INTERPOLATE">INTERPOLATE</a></li>
<li class="subsub"><a href="#section_ANYCASE">ANYCASE</a></li>
<li class="sub"><a href="#section_Template_Files_and_Blocks">Template Files and Blocks</a></li>
<li class="subsub"><a href="#section_INCLUDE_PATH">INCLUDE_PATH</a></li>
<li class="subsub"><a href="#section_DELIMITER">DELIMITER</a></li>
<li class="subsub"><a href="#section_ABSOLUTE">ABSOLUTE</a></li>
<li class="subsub"><a href="#section_RELATIVE">RELATIVE</a></li>
<li class="subsub"><a href="#section_DEFAULT">DEFAULT</a></li>
<li class="subsub"><a href="#section_BLOCKS">BLOCKS</a></li>
<li class="subsub"><a href="#section_AUTO_RESET">AUTO_RESET</a></li>
<li class="subsub"><a href="#section_RECURSION">RECURSION</a></li>
<li class="sub"><a href="#section_Template_Variables">Template Variables</a></li>
<li class="subsub"><a href="#section_VARIABLES">VARIABLES</a></li>
<li class="sub"><a href="#section_Runtime_Processing_Options">Runtime Processing Options</a></li>
<li class="subsub"><a href="#section_EVAL_PERL">EVAL_PERL</a></li>
<li class="subsub"><a href="#section_PRE_PROCESS_POST_PROCESS">PRE_PROCESS, POST_PROCESS</a></li>
<li class="subsub"><a href="#section_PROCESS">PROCESS</a></li>
<li class="subsub"><a href="#section_ERROR">ERROR</a></li>
<li class="subsub"><a href="#section_OUTPUT">OUTPUT</a></li>
<li class="subsub"><a href="#section_OUTPUT_PATH">OUTPUT_PATH</a></li>
<li class="subsub"><a href="#section_DEBUG">DEBUG</a></li>
<li class="sub"><a href="#section_Caching_and_Compiling_Options">Caching and Compiling Options</a></li>
<li class="subsub"><a href="#section_CACHE_SIZE">CACHE_SIZE</a></li>
<li class="subsub"><a href="#section_COMPILE_EXT">COMPILE_EXT</a></li>
<li class="subsub"><a href="#section_COMPILE_DIR">COMPILE_DIR</a></li>
<li class="sub"><a href="#section_Plugins_and_Filters">Plugins and Filters</a></li>
<li class="subsub"><a href="#section_PLUGINS">PLUGINS</a></li>
<li class="subsub"><a href="#section_PLUGIN_BASE">PLUGIN_BASE</a></li>
<li class="subsub"><a href="#section_LOAD_PERL">LOAD_PERL</a></li>
<li class="subsub"><a href="#section_FILTERS">FILTERS</a></li>
<li class="sub"><a href="#section_Customisation_and_Extension">Customisation and Extension</a></li>
<li class="subsub"><a href="#section_LOAD_TEMPLATES">LOAD_TEMPLATES</a></li>
<li class="subsub"><a href="#section_LOAD_PLUGINS">LOAD_PLUGINS</a></li>
<li class="subsub"><a href="#section_LOAD_FILTERS">LOAD_FILTERS</a></li>
<li class="subsub"><a href="#section_TOLERANT">TOLERANT</a></li>
<li class="subsub"><a href="#section_SERVICE">SERVICE</a></li>
<li class="subsub"><a href="#section_CONTEXT">CONTEXT</a></li>
<li class="subsub"><a href="#section_STASH">STASH</a></li>
<li class="subsub"><a href="#section_PARSER">PARSER</a></li>
<li class="subsub"><a href="#section_GRAMMAR">GRAMMAR</a></li>
<li class=""><a href="#DIRECTIVE_SUMMARY">DIRECTIVE SUMMARY</a></li>
<li class="sub"><a href="#section_GET">GET</a></li>
<li class="sub"><a href="#section_CALL">CALL</a></li>
<li class="sub"><a href="#section_SET">SET</a></li>
<li class="sub"><a href="#section_DEFAULT">DEFAULT</a></li>
<li class="sub"><a href="#section_INSERT">INSERT</a></li>
<li class="sub"><a href="#section_PROCESS">PROCESS</a></li>
<li class="sub"><a href="#section_INCLUDE">INCLUDE</a></li>
<li class="sub"><a href="#section_WRAPPER">WRAPPER</a></li>
<li class="sub"><a href="#section_BLOCK">BLOCK</a></li>
<li class="sub"><a href="#section_FOREACH">FOREACH</a></li>
<li class="sub"><a href="#section_WHILE">WHILE</a></li>
<li class="sub"><a href="#section_IF_UNLESS_ELSIF_ELSE">IF / UNLESS / ELSIF / ELSE</a></li>
<li class="sub"><a href="#section_SWITCH_CASE">SWITCH / CASE</a></li>
<li class="sub"><a href="#section_MACRO">MACRO</a></li>
<li class="sub"><a href="#section_FILTER">FILTER</a></li>
<li class="sub"><a href="#section_USE">USE</a></li>
<li class="sub"><a href="#section_PERL_RAWPERL">PERL / RAWPERL</a></li>
<li class="sub"><a href="#section_TRY_THROW_CATCH_FINAL">TRY / THROW / CATCH / FINAL</a></li>
<li class="sub"><a href="#section_NEXT">NEXT</a></li>
<li class="sub"><a href="#section_LAST">LAST</a></li>
<li class="sub"><a href="#section_RETURN">RETURN</a></li>
<li class="sub"><a href="#section_STOP">STOP</a></li>
<li class="sub"><a href="#section_TAGS">TAGS</a></li>
<li class="sub"><a href="#section_COMMENTS">COMMENTS</a></li>
<li class=""><a href="#SOURCE_CODE_REPOSITORY">SOURCE CODE REPOSITORY</a></li>
<li class=""><a href="#AUTHOR">AUTHOR</a></li>
<li class=""><a href="#VERSION">VERSION</a></li>
<li class=""><a href="#COPYRIGHT">COPYRIGHT</a></li>
</ul>
</div>
</div>
<div class="pod">
<div class="section">
<div class="head">
<h1 id="SYNOPSIS" onclick="switch_section(this)" title="Click title to show/hide section content.">SYNOPSIS</h1>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<pre>use Template;
# some useful options (see below for full list)
my $config = {
INCLUDE_PATH => '/search/path', # or list ref
INTERPOLATE => 1, # expand "$var" in plain text
POST_CHOMP => 1, # cleanup whitespace
PRE_PROCESS => 'header', # prefix each template
EVAL_PERL => 1, # evaluate Perl code blocks
};
# create Template object
my $template = Template->new($config);
# define template variables for replacement
my $vars = {
var1 => $value,
var2 => \%hash,
var3 => \@list,
var4 => \&code,
var5 => $object,
};
# specify input filename, or file handle, text reference, etc.
my $input = 'myfile.html';
# process input template, substituting variables
$template->process($input, $vars)
|| die $template->error();</pre>
</div>
</div>
<div class="section">
<div class="head">
<h1 id="DESCRIPTION" onclick="switch_section(this)" title="Click title to show/hide section content.">DESCRIPTION</h1>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
This documentation describes the Template module which is the direct Perl
interface into the Template Toolkit. It covers the use of the module and
gives a brief summary of configuration options and template directives.
Please see <a href="../manual/index.html">Template::Manual</a> for the complete reference manual which goes
into much greater depth about the features and use of the Template
Toolkit. The <a href="../tutorial/index.html">Template::Tutorial</a> is also available as an introductory guide to
using the Template Toolkit.
</p>
</div>
</div>
<div class="section">
<div class="head">
<h1 id="METHODS" onclick="switch_section(this)" title="Click title to show/hide section content.">METHODS</h1>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<div class="subsection">
<div class="head">
<h2 id="method_new" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">new(\%config)</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
The <code>new()</code> constructor method (implemented by the <a
href="../modules/Template/Base.html#method_new">Template::Base</a>
base class) instantiates a new <code>Template</code> object. A reference
to a hash array of configuration items may be passed as a parameter.
</p>
<pre>my $tt = Template->new({
INCLUDE_PATH => '/usr/local/templates',
EVAL_PERL => 1,
}) || die $Template::ERROR, "\n";</pre>
<p>
A reference to a new <code>Template</code> object is returned, or undef
on error. In the latter case, the error message can be retrieved by
calling <a href="#method_error">error()</a> as a class method or by
examining the <code>$Template::ERROR</code> package variable directly.
</p>
<pre>my $tt = Template->new(\%config)
|| die Template->error(), "\n";
my $tt = Template->new(\%config)
|| die $Template::ERROR, "\n";</pre>
<p>
For convenience, configuration items may also be specified as a list of
items instead of a hash array reference. These are automatically folded
into a hash array by the constructor.
</p>
<pre>my $tt = Template->new(INCLUDE_PATH => '/tmp', POST_CHOMP => 1)
|| die $Template::ERROR, "\n";</pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="method_process" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">process($template, \%vars, $output, %options)</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
The <code>process()</code> method is called to process a template. The
first parameter indicates the input template as one of: a filename
relative to <code>INCLUDE_PATH</code>, if defined; a reference to a text
string containing the template text; or a file handle reference (e.g.
<code>IO::Handle</code> or sub-class) or <code>GLOB</code> (e.g.
<code>\*STDIN</code>), from which the template can be read. A reference
to a hash array may be passed as the second parameter, containing
definitions of template variables.
</p>
<pre># filename
$tt->process('welcome.tt2')
|| die $tt->error(), "\n";
# text reference
$text = "<span class="tt">[% INCLUDE header %]</span>\nHello world!\n<span class="tt">[% INCLUDE footer %]</span>";
$tt->process(\$text)
|| die $tt->error(), "\n";
# file handle (GLOB)
$tt->process(\*DATA)
|| die $tt->error(), "\n";
__END__
<span class="tt">[% INCLUDE header %]</span>
This is a template defined in the __END__ section which is
accessible via the DATA "file handle".
<span class="tt">[% INCLUDE footer %]</span></pre>
<p>
By default, the processed template output is printed to
<code>STDOUT</code>. The <code>process()</code> method then returns
<code>1</code> to indicate success. A third parameter may be passed to
the <code>process()</code> method to specify a different output location.
This value may be one of: a plain string indicating a filename which will
be opened (relative to <code>OUTPUT_PATH</code>, if defined) and the
output written to; a file GLOB opened ready for output; a reference to a
scalar (e.g. a text string) to which output/error is appended; a
reference to a subroutine which is called, passing the output as a
parameter; or any object reference which implements a
<code>print()</code> method (e.g. <code>IO::Handle</code>,
<code>Apache::Request</code>, etc.) which will be called, passing the
generated output as a parameter.
</p>
<p>
Examples:
</p>
<pre># output filename
$tt->process('welcome.tt2', $vars, 'welcome.html')
|| die $tt->error(), "\n";
# reference to output subroutine
sub myout {
my $output = shift;
...
}
$tt->process('welcome.tt2', $vars, \&myout)
|| die $tt->error(), "\n";
# reference to output text string
my $output = '';
$tt->process('welcome.tt2', $vars, \$output)
|| die $tt->error(), "\n";
print "output: $output\n";</pre>
<p>
In an Apache/mod_perl handler:
</p>
<pre>sub handler {
my $req = shift;
# ...your code here...
# direct output to Apache::Request via $req->print($output)
$tt->process($file, $vars, $req) || do {
$req->log_reason($tt->error());
return SERVER_ERROR;
};
return OK;
}</pre>
<p>
After the optional third output argument can come an optional reference
to a hash or a list of <code>(name, value)</code> pairs providing further
options for the output. The only option currently supported is
<code>binmode</code> which, when set to any true value will ensure that
files created (but not any existing file handles passed) will be set to
binary mode.
</p>
<pre># either: hash reference of options
$tt->process($infile, $vars, $outfile, { binmode => 1 })
|| die $tt->error(), "\n";
# or: list of name, value pairs
$tt->process($infile, $vars, $outfile, binmode => 1)
|| die $tt->error(), "\n";</pre>
<p>
Alternately, the <code>binmode</code> argument can specify a particular
IO layer such as <code>:utf8</code>.
</p>
<pre>$tt->process($infile, $vars, $outfile, binmode => ':utf8')
|| die $tt->error(), "\n";</pre>
<p>
The <code>OUTPUT</code> configuration item can be used to specify a
default output location other than <code>\*STDOUT</code>. The
<code>OUTPUT_PATH</code> specifies a directory which should be prefixed
to all output locations specified as filenames.
</p>
<pre>my $tt = Template->new({
OUTPUT => sub { ... }, # default
OUTPUT_PATH => '/tmp',
...
}) || die Template->error(), "\n";
# use default OUTPUT (sub is called)
$tt->process('welcome.tt2', $vars)
|| die $tt->error(), "\n";
# write file to '/tmp/welcome.html'
$tt->process('welcome.tt2', $vars, 'welcome.html')
|| die $tt->error(), "\n";</pre>
<p>
The <code>process()</code> method returns <code>1</code> on success or
<code>undef</code> on error. The error message generated in the latter
case can be retrieved by calling the <a href="#method_error">error()</a>
method. See also <a href="#CONFIGURATION_SUMMARY">CONFIGURATION
SUMMARY</a> which describes how error handling may be further customised.
</p>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="method_error" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">error()</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
When called as a class method, it returns the value of the
<code>$ERROR</code> package variable. Thus, the following are equivalent.
</p>
<pre>my $tt = Template->new()
|| die Template->error(), "\n";
my $tt = Template->new()
|| die $Template::ERROR, "\n";</pre>
<p>
When called as an object method, it returns the value of the internal
<code>_ERROR</code> variable, as set by an error condition in a previous
call to process().
</p>
<pre>$tt->process('welcome.tt2')
|| die $tt->error(), "\n";</pre>
<p>
Errors are represented in the Template Toolkit by objects of the <a
href="../modules/Template/Exception.html">Template::Exception</a>
class. If the <a href="#method_process">process()</a> method returns a
false value then the <code>error()</code> method can be called to return
an object of this class. The <a href="../modules/Template/Exception.html#method_type">type()</a> and <a
href="../modules/Template/Exception.html#method_info">info()</a>
methods can called on the object to retrieve the error type and
information string, respectively. The <a href="../modules/Template/Exception.html#method_as_string">as_string()</a>
method can be called to return a string of the form <code>$type -
$info</code>. This method is also overloaded onto the stringification
operator allowing the object reference itself to be printed to return the
formatted error string.
</p>
<pre>$tt->process('somefile') || do {
my $error = $tt->error();
print "error type: ", $error->type(), "\n";
print "error info: ", $error->info(), "\n";
print $error, "\n";
};</pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="method_service" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">service()</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
The <code>Template</code> module delegates most of the effort of
processing templates to an underlying <a href="../modules/Template/Service.html">Template::Service</a> object. This
method returns a reference to that object.
</p>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="method_context" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">context()</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
The <a href="../modules/Template/Service.html">Template::Service</a> module uses a core <a href="../modules/Template/Context.html">Template::Context</a> object for
runtime processing of templates. This method returns a reference to that
object and is equivalent to
<code>$template->service->context()</code>.
</p>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="method_template" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">template($name)</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
This method is a simple wrapper around the <a href="../modules/Template/Context.html">Template::Context</a> method of the
same name. It returns a compiled template for the source provided as an
argument.
</p>
</div>
</div>
</div>
</div>
<div class="section">
<div class="head">
<h1 id="CONFIGURATION_SUMMARY" onclick="switch_section(this)" title="Click title to show/hide section content.">CONFIGURATION SUMMARY</h1>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
The following list gives a short summary of each Template Toolkit
configuration option. See <a href="../manual/Config.html">Template::Manual::Config</a>
for full details.
</p>
<div class="subsection">
<div class="head">
<h2 id="section_Template_Style_and_Parsing_Options" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">Template Style and Parsing Options</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<h3 class="method" id="section_START_TAG_END_TAG">START_TAG, END_TAG</h3>
<p>
Define tokens that indicate start and end of directives (default:
'<code>[%</code>' and '<code>%]</code>').
</p>
<h3 class="method" id="section_TAG_STYLE">TAG_STYLE</h3>
<p>
Set <code>START_TAG</code> and <code>END_TAG</code> according to a
pre-defined style (default: '<code>template</code>', as above).
</p>
<h3 class="method" id="section_PRE_CHOMP_POST_CHOMP">PRE_CHOMP, POST_CHOMP</h3>
<p>
Removes whitespace before/after directives (default: 0/0).
</p>
<h3 class="method" id="section_TRIM">TRIM</h3>
<p>
Remove leading and trailing whitespace from template output (default: 0).
</p>
<h3 class="method" id="section_INTERPOLATE">INTERPOLATE</h3>
<p>
Interpolate variables embedded like <code>$this</code> or
<code>${this}</code> (default: 0).
</p>
<h3 class="method" id="section_ANYCASE">ANYCASE</h3>
<p>
Allow directive keywords in lower case (default: 0 - UPPER only).
</p>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_Template_Files_and_Blocks" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">Template Files and Blocks</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<h3 class="method" id="section_INCLUDE_PATH">INCLUDE_PATH</h3>
<p>
One or more directories to search for templates.
</p>
<h3 class="method" id="section_DELIMITER">DELIMITER</h3>
<p>
Delimiter for separating paths in <code>INCLUDE_PATH</code> (default:
'<code>:</code>').
</p>
<h3 class="method" id="section_ABSOLUTE">ABSOLUTE</h3>
<p>
Allow absolute file names, e.g. <code>/foo/bar.html</code> (default: 0).
</p>
<h3 class="method" id="section_RELATIVE">RELATIVE</h3>
<p>
Allow relative filenames, e.g. <code>../foo/bar.html</code> (default: 0).
</p>
<h3 class="method" id="section_DEFAULT">DEFAULT</h3>
<p>
Default template to use when another not found.
</p>
<h3 class="method" id="section_BLOCKS">BLOCKS</h3>
<p>
Hash array pre-defining template blocks.
</p>
<h3 class="method" id="section_AUTO_RESET">AUTO_RESET</h3>
<p>
Enabled by default causing <code>BLOCK</code> definitions to be reset
each time a template is processed. Disable to allow <code>BLOCK</code>
definitions to persist.
</p>
<h3 class="method" id="section_RECURSION">RECURSION</h3>
<p>
Flag to permit recursion into templates (default: 0).
</p>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_Template_Variables" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">Template Variables</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<h3 class="method" id="section_VARIABLES">VARIABLES</h3>
<p>
Hash array of variables and values to pre-define in the stash.
</p>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_Runtime_Processing_Options" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">Runtime Processing Options</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<h3 class="method" id="section_EVAL_PERL">EVAL_PERL</h3>
<p>
Flag to indicate if <code>PERL</code>/<code>RAWPERL</code> blocks should
be processed (default: 0).
</p>
<h3 class="method" id="section_PRE_PROCESS_POST_PROCESS">PRE_PROCESS, POST_PROCESS</h3>
<p>
Name of template(s) to process before/after main template.
</p>
<h3 class="method" id="section_PROCESS">PROCESS</h3>
<p>
Name of template(s) to process instead of main template.
</p>
<h3 class="method" id="section_ERROR">ERROR</h3>
<p>
Name of error template or reference to hash array mapping error types to
templates.
</p>
<h3 class="method" id="section_OUTPUT">OUTPUT</h3>
<p>
Default output location or handler.
</p>
<h3 class="method" id="section_OUTPUT_PATH">OUTPUT_PATH</h3>
<p>
Directory into which output files can be written.
</p>
<h3 class="method" id="section_DEBUG">DEBUG</h3>
<p>
Enable debugging messages.
</p>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_Caching_and_Compiling_Options" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">Caching and Compiling Options</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<h3 class="method" id="section_CACHE_SIZE">CACHE_SIZE</h3>
<p>
Maximum number of compiled templates to cache in memory (default: undef -
cache all)
</p>
<h3 class="method" id="section_COMPILE_EXT">COMPILE_EXT</h3>
<p>
Filename extension for compiled template files (default: undef - don't
compile).
</p>
<h3 class="method" id="section_COMPILE_DIR">COMPILE_DIR</h3>
<p>
Root of directory in which compiled template files should be written
(default: undef - don't compile).
</p>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_Plugins_and_Filters" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">Plugins and Filters</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<h3 class="method" id="section_PLUGINS">PLUGINS</h3>
<p>
Reference to a hash array mapping plugin names to Perl packages.
</p>
<h3 class="method" id="section_PLUGIN_BASE">PLUGIN_BASE</h3>
<p>
One or more base classes under which plugins may be found.
</p>
<h3 class="method" id="section_LOAD_PERL">LOAD_PERL</h3>
<p>
Flag to indicate regular Perl modules should be loaded if a named plugin
can't be found (default: 0).
</p>
<h3 class="method" id="section_FILTERS">FILTERS</h3>
<p>
Hash array mapping filter names to filter subroutines or factories.
</p>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_Customisation_and_Extension" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">Customisation and Extension</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<h3 class="method" id="section_LOAD_TEMPLATES">LOAD_TEMPLATES</h3>
<p>
List of template providers.
</p>
<h3 class="method" id="section_LOAD_PLUGINS">LOAD_PLUGINS</h3>
<p>
List of plugin providers.
</p>
<h3 class="method" id="section_LOAD_FILTERS">LOAD_FILTERS</h3>
<p>
List of filter providers.
</p>
<h3 class="method" id="section_TOLERANT">TOLERANT</h3>
<p>
Set providers to tolerate errors as declinations (default: 0).
</p>
<h3 class="method" id="section_SERVICE">SERVICE</h3>
<p>
Reference to a custom service object (default: <a href="../modules/Template/Service.html">Template::Service</a>).
</p>
<h3 class="method" id="section_CONTEXT">CONTEXT</h3>
<p>
Reference to a custom context object (default: <a href="../modules/Template/Context.html">Template::Context</a>).
</p>
<h3 class="method" id="section_STASH">STASH</h3>
<p>
Reference to a custom stash object (default: <a href="../modules/Template/Stash.html">Template::Stash</a>).
</p>
<h3 class="method" id="section_PARSER">PARSER</h3>
<p>
Reference to a custom parser object (default: <a href="../modules/Template/Parser.html">Template::Parser</a>).
</p>
<h3 class="method" id="section_GRAMMAR">GRAMMAR</h3>
<p>
Reference to a custom grammar object (default: <a href="../modules/Template/Grammar.html">Template::Grammar</a>).
</p>
</div>
</div>
</div>
</div>
<div class="section">
<div class="head">
<h1 id="DIRECTIVE_SUMMARY" onclick="switch_section(this)" title="Click title to show/hide section content.">DIRECTIVE SUMMARY</h1>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
The following list gives a short summary of each Template Toolkit
directive. See <a href="../manual/Directives.html">Template::Manual::Directives</a> for full details.
</p>
<div class="subsection">
<div class="head">
<h2 id="section_GET" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">GET</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Evaluate and print a variable or value.
</p>
<pre><span class="tt">[% GET variable %]</span> # 'GET' keyword is optional
<span class="tt">[% variable %]</span>
<span class="tt">[% hash.key %]</span>
<span class="tt">[% list.n %]</span>
<span class="tt">[% code(args) %]</span>
<span class="tt">[% obj.meth(args) %]</span>
<span class="tt">[% "value: $var" %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_CALL" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">CALL</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
As per <a href="#section_GET">GET</a> but without printing result (e.g.
call code)
</p>
<pre><span class="tt">[% CALL variable %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_SET" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">SET</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Assign a values to variables.
</p>
<pre><span class="tt">[% SET variable = value %]</span> # 'SET' also optional
<span class="tt">[% variable = other_variable
variable = 'literal text @ $100'
variable = "interpolated text: $var"
list = [ val, val, val, val, ... ]
list = [ val..val ]
hash = { var => val, var => val, ... }
%]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_DEFAULT" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">DEFAULT</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Like <a href="#section_SET">SET</a>, but variables are only set if
currently unset (i.e. have no true value).
</p>
<pre><span class="tt">[% DEFAULT variable = value %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_INSERT" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">INSERT</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Insert a file without any processing performed on the contents.
</p>
<pre><span class="tt">[% INSERT legalese.txt %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_PROCESS" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">PROCESS</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Process another template file or block and insert the generated output.
Any template <a href="#section_BLOCK">BLOCK</a>s or variables defined or
updated in the <code>PROCESS</code>ed template will thereafter be defined
in the calling template.
</p>
<pre><span class="tt">[% PROCESS template %]</span>
<span class="tt">[% PROCESS template var = val, ... %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_INCLUDE" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">INCLUDE</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Similar to <code>PROCESS</code>, but using a local copy of the current
variables. Any template <code>BLOCK</code>s or variables defined in the
<code>INCLUDE</code>d template remain local to it.
</p>
<pre><span class="tt">[% INCLUDE template %]</span>
<span class="tt">[% INCLUDE template var = val, ... %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_WRAPPER" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">WRAPPER</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
The content between the <code>WRAPPER</code> and correspondng
<code>END</code> directives is first evaluated, with the output generated
being stored in the <code>content</code> variable. The named template is
then process as per <code>INCLUDE</code>.
</p>
<pre><span class="tt">[% WRAPPER layout %]</span>
Some template markup <span class="tt">[% blah %]</span>...
<span class="tt">[% END %]</span></pre>
<p>
A simple <i>layout</i> template might look something like this:
</p>
<pre>Your header here...
<span class="tt">[% content %]</span>
Your footer here...</pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_BLOCK" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">BLOCK</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Define a named template block for <a href="#section_INCLUDE">INCLUDE</a>,
<a href="#section_PROCESS">PROCESS</a> and <a
href="#section_WRAPPER">WRAPPER</a> to use.
</p>
<pre><span class="tt">[% BLOCK hello %]</span>
Hello World
<span class="tt">[% END %]</span>
<span class="tt">[% INCLUDE hello %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_FOREACH" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">FOREACH</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Repeat the enclosed <code>FOREACH</code> ... <code>END</code> block for
each value in the list.
</p>
<pre><span class="tt">[% FOREACH variable IN [ val, val, val ] %]</span> # either
<span class="tt">[% FOREACH variable IN list %]</span> # or
The variable is set to <span class="tt">[% variable %]</span>
<span class="tt">[% END %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_WHILE" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">WHILE</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
The block enclosed between <code>WHILE</code> and <code>END</code> block
is processed while the specified condition is true.
</p>
<pre><span class="tt">[% WHILE condition %]</span>
content
<span class="tt">[% END %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_IF_UNLESS_ELSIF_ELSE" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">IF / UNLESS / ELSIF / ELSE</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
The enclosed block is processed if the condition is true / false.
</p>
<pre><span class="tt">[% IF condition %]</span>
content
<span class="tt">[% ELSIF condition %]</span>
content
<span class="tt">[% ELSE %]</span>
content
<span class="tt">[% END %]</span>
<span class="tt">[% UNLESS condition %]</span>
content
<span class="tt">[% # ELSIF/ELSE as per IF, above %]</span>
content
<span class="tt">[% END %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_SWITCH_CASE" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">SWITCH / CASE</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Multi-way switch/case statement.
</p>
<pre><span class="tt">[% SWITCH variable %]</span>
<span class="tt">[% CASE val1 %]</span>
content
<span class="tt">[% CASE [ val2, val3 ] %]</span>
content
<span class="tt">[% CASE %]</span> # or <span class="tt">[% CASE DEFAULT %]</span>
content
<span class="tt">[% END %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_MACRO" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">MACRO</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Define a named macro.
</p>
<pre><span class="tt">[% MACRO name <directive> %]</span>
<span class="tt">[% MACRO name(arg1, arg2) <directive> %]</span>
...
<span class="tt">[% name %]</span>
<span class="tt">[% name(val1, val2) %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_FILTER" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">FILTER</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Process enclosed <code>FILTER</code> ... <code>END</code> block then pipe
through a filter.
</p>
<pre><span class="tt">[% FILTER name %]</span> # either
<span class="tt">[% FILTER name( params ) %]</span> # or
<span class="tt">[% FILTER alias = name( params ) %]</span> # or
content
<span class="tt">[% END %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_USE" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">USE</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Load a plugin module (see <code>Template::<Manual::Plugins</code>), or
any regular Perl module when the <code>LOAD_PERL</code> option is set.
</p>
<pre><span class="tt">[% USE name %]</span> # either
<span class="tt">[% USE name( params ) %]</span> # or
<span class="tt">[% USE var = name( params ) %]</span> # or
...
<span class="tt">[% name.method %]</span>
<span class="tt">[% var.method %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_PERL_RAWPERL" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">PERL / RAWPERL</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Evaluate enclosed blocks as Perl code (requires the
<code>EVAL_PERL</code> option to be set).
</p>
<pre><span class="tt">[% PERL %]</span>
# perl code goes here
$stash->set('foo', 10);
print "set 'foo' to ", $stash->get('foo'), "\n";
print $context->include('footer', { var => $val });
<span class="tt">[% END %]</span>
<span class="tt">[% RAWPERL %]</span>
# raw perl code goes here, no magic but fast.
$output .= 'some output';
<span class="tt">[% END %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_TRY_THROW_CATCH_FINAL" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">TRY / THROW / CATCH / FINAL</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Exception handling.
</p>
<pre><span class="tt">[% TRY %]</span>
content
<span class="tt">[% THROW type info %]</span>
<span class="tt">[% CATCH type %]</span>
catch content
<span class="tt">[% error.type %]</span> <span class="tt">[% error.info %]</span>
<span class="tt">[% CATCH %]</span> # or <span class="tt">[% CATCH DEFAULT %]</span>
content
<span class="tt">[% FINAL %]</span>
this block is always processed
<span class="tt">[% END %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_NEXT" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">NEXT</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Jump straight to the next item in a <code>FOREACH</code> or
<code>WHILE</code> loop.
</p>
<pre><span class="tt">[% NEXT %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_LAST" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">LAST</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Break out of <code>FOREACH</code> or <code>WHILE</code> loop.
</p>
<pre><span class="tt">[% LAST %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_RETURN" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">RETURN</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Stop processing current template and return to including templates.
</p>
<pre><span class="tt">[% RETURN %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_STOP" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">STOP</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Stop processing all templates and return to caller.
</p>
<pre><span class="tt">[% STOP %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_TAGS" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">TAGS</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Define new tag style or characters (default: <code>[%</code>
<code>%]</code>).
</p>
<pre><span class="tt">[% TAGS html %]</span>
<span class="tt">[% TAGS <!-- --> %]</span></pre>
</div>
</div> <div class="subsection">
<div class="head">
<h2 id="section_COMMENTS" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">COMMENTS</h2>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Ignored and deleted.
</p>
<pre><span class="tt">[% # this is a comment to the end of line
foo = 'bar'
%]</span>
<span class="tt">[%# placing the '#' immediately inside the directive
tag comments out the entire directive
%]</span></pre>
</div>
</div>
</div>
</div>
<div class="section">
<div class="head">
<h1 id="SOURCE_CODE_REPOSITORY" onclick="switch_section(this)" title="Click title to show/hide section content.">SOURCE CODE REPOSITORY</h1>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
The source code for the Template Toolkit is held in a public git
repository on Github: <a
href="https://github.com/abw/Template2">https://github.com/abw/Template2</a>
</p>
</div>
</div>
<div class="section">
<div class="head">
<h1 id="AUTHOR" onclick="switch_section(this)" title="Click title to show/hide section content.">AUTHOR</h1>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Andy Wardley <abw@wardley.org> <a
href="http://wardley.org/">http://wardley.org/</a>
</p>
</div>
</div>
<div class="section">
<div class="head">
<h1 id="VERSION" onclick="switch_section(this)" title="Click title to show/hide section content.">VERSION</h1>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Template Toolkit version 2.24, released February 2012.
</p>
</div>
</div>
<div class="section">
<div class="head">
<h1 id="COPYRIGHT" onclick="switch_section(this)" title="Click title to show/hide section content.">COPYRIGHT</h1>
<a href="#body" class="top" title="Back up to the top of the page" >Top</a>
</div>
<div class="body">
<p>
Copyright (C) 1996-2012 Andy Wardley. All Rights Reserved.
</p>
<p>
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
</p>
</div>
</div>
</div></div>
<br class="clear" />
<div class="pageinfo">
<a href="http://template-toolkit.org/docs/modules/Template.html">http://template-toolkit.org/docs/modules/Template.html</a>
</div>
</div>
<div id="footer">
<a href="http://opensource.org/" class="osi"></a>
<div class="controls">
<div class="pager">
<span class="go back">Back<span class="about"></span></span>
<a href="../modules/index.html" title="Template::Modules" class="go up">Up<span class="about"><h4>Template::Modules</h4></span></a>
<a href="../modules/Template/index.html" title="Template::* Modules" class="go next">Next<span class="about"><h4>Template::* Modules</h4></span></a>
</div>
</div>
<div class="copyright">
Copyright © 1996-2012 <a href="http://wardley.org/">Andy Wardley</a>. All Rights Reserved.
</div>
<div class="licence">
The <a href="http://template-toolkit.org/">Template Toolkit</a> is <a href="http://opensource.org/">Open Source</a> software.
You can redistribute and/or modify it under the terms of the <a href="http://www.opensource.org/licenses/gpl-license.php">GNU Public Licence</a>
or the <a href="http://www.opensource.org/licenses/artistic-license.php">Perl Artistic Licence</a>.
</div>
</div>
<div id="palette">
<ul>
<li class="first"><a href="#" class="blue" onclick="set_style('Clear Blue')"></a></li>
<li><a href="#" class="orange" onclick="set_style('Clear Orange')"></a></li>
<li><a href="#" class="green" onclick="set_style('Clear Green')"></a></li>
<li><a href="#" class="purple" onclick="set_style('Clear Purple')"></a></li>
<li><a href="#" class="grey" onclick="set_style('Clear Grey')"></a></li>
</ul>
</div>
</div> </body>
</html>
|