1Text::Template(3)     User Contributed Perl Documentation    Text::Template(3)
2
3
4

NAME

6       Text::Template - Expand template text with embedded Perl
7

VERSION

9       version 1.55
10

SYNOPSIS

12        use Text::Template;
13
14
15        $template = Text::Template->new(TYPE => 'FILE',  SOURCE => 'filename.tmpl');
16        $template = Text::Template->new(TYPE => 'ARRAY', SOURCE => [ ... ] );
17        $template = Text::Template->new(TYPE => 'FILEHANDLE', SOURCE => $fh );
18        $template = Text::Template->new(TYPE => 'STRING', SOURCE => '...' );
19        $template = Text::Template->new(PREPEND => q{use strict;}, ...);
20
21        # Use a different template file syntax:
22        $template = Text::Template->new(DELIMITERS => [$open, $close], ...);
23
24        $recipient = 'King';
25        $text = $template->fill_in();  # Replaces `{$recipient}' with `King'
26        print $text;
27
28        $T::recipient = 'Josh';
29        $text = $template->fill_in(PACKAGE => T);
30
31        # Pass many variables explicitly
32        $hash = { recipient => 'Abed-Nego',
33                  friends => [ 'me', 'you' ],
34                  enemies => { loathsome => 'Saruman',
35                               fearsome => 'Sauron' },
36                };
37        $text = $template->fill_in(HASH => $hash, ...);
38        # $recipient is Abed-Nego,
39        # @friends is ( 'me', 'you' ),
40        # %enemies is ( loathsome => ..., fearsome => ... )
41
42
43        # Call &callback in case of programming errors in template
44        $text = $template->fill_in(BROKEN => \&callback, BROKEN_ARG => $ref, ...);
45
46        # Evaluate program fragments in Safe compartment with restricted permissions
47        $text = $template->fill_in(SAFE => $compartment, ...);
48
49        # Print result text instead of returning it
50        $success = $template->fill_in(OUTPUT => \*FILEHANDLE, ...);
51
52        # Parse template with different template file syntax:
53        $text = $template->fill_in(DELIMITERS => [$open, $close], ...);
54        # Note that this is *faster* than using the default delimiters
55
56        # Prepend specified perl code to each fragment before evaluating:
57        $text = $template->fill_in(PREPEND => q{use strict 'vars';}, ...);
58
59        use Text::Template 'fill_in_string';
60        $text = fill_in_string( <<EOM, PACKAGE => 'T', ...);
61        Dear {$recipient},
62        Pay me at once.
63               Love,
64                G.V.
65        EOM
66
67        use Text::Template 'fill_in_file';
68        $text = fill_in_file($filename, ...);
69
70        # All templates will always have `use strict vars' attached to all fragments
71        Text::Template->always_prepend(q{use strict 'vars';});
72

DESCRIPTION

74       This is a library for generating form letters, building HTML pages, or
75       filling in templates generally.  A `template' is a piece of text that
76       has little Perl programs embedded in it here and there.  When you `fill
77       in' a template, you evaluate the little programs and replace them with
78       their values.
79
80       You can store a template in a file outside your program.  People can
81       modify the template without modifying the program.  You can separate
82       the formatting details from the main code, and put the formatting parts
83       of the program into the template.  That prevents code bloat and
84       encourages functional separation.
85
86   Example
87       Here's an example of a template, which we'll suppose is stored in the
88       file "formletter.tmpl":
89
90           Dear {$title} {$lastname},
91
92           It has come to our attention that you are delinquent in your
93           {$monthname[$last_paid_month]} payment.  Please remit
94           ${sprintf("%.2f", $amount)} immediately, or your patellae may
95           be needlessly endangered.
96
97                           Love,
98
99                           Mark "Vizopteryx" Dominus
100
101       The result of filling in this template is a string, which might look
102       something like this:
103
104           Dear Mr. Smith,
105
106           It has come to our attention that you are delinquent in your
107           February payment.  Please remit
108           $392.12 immediately, or your patellae may
109           be needlessly endangered.
110
111
112                           Love,
113
114                           Mark "Vizopteryx" Dominus
115
116       Here is a complete program that transforms the example template into
117       the example result, and prints it out:
118
119           use Text::Template;
120
121           my $template = Text::Template->new(SOURCE => 'formletter.tmpl')
122             or die "Couldn't construct template: $Text::Template::ERROR";
123
124           my @monthname = qw(January February March April May June
125                              July August September October November December);
126           my %vars = (title           => 'Mr.',
127                       firstname       => 'John',
128                       lastname        => 'Smith',
129                       last_paid_month => 1,   # February
130                       amount          => 392.12,
131                       monthname       => \@monthname);
132
133           my $result = $template->fill_in(HASH => \%vars);
134
135           if (defined $result) { print $result }
136           else { die "Couldn't fill in template: $Text::Template::ERROR" }
137
138   Philosophy
139       When people make a template module like this one, they almost always
140       start by inventing a special syntax for substitutions.  For example,
141       they build it so that a string like "%%VAR%%" is replaced with the
142       value of $VAR.  Then they realize the need extra formatting, so they
143       put in some special syntax for formatting.  Then they need a loop, so
144       they invent a loop syntax.  Pretty soon they have a new little template
145       language.
146
147       This approach has two problems: First, their little language is
148       crippled. If you need to do something the author hasn't thought of, you
149       lose.  Second: Who wants to learn another language?  You already know
150       Perl, so why not use it?
151
152       "Text::Template" templates are programmed in Perl.  You embed Perl code
153       in your template, with "{" at the beginning and "}" at the end.  If you
154       want a variable interpolated, you write it the way you would in Perl.
155       If you need to make a loop, you can use any of the Perl loop
156       constructions.  All the Perl built-in functions are available.
157

Details

159   Template Parsing
160       The "Text::Template" module scans the template source.  An open brace
161       "{" begins a program fragment, which continues until the matching close
162       brace "}".  When the template is filled in, the program fragments are
163       evaluated, and each one is replaced with the resulting value to yield
164       the text that is returned.
165
166       A backslash "\" in front of a brace (or another backslash that is in
167       front of a brace) escapes its special meaning.  The result of filling
168       out this template:
169
170           \{ The sum of 1 and 2 is {1+2}  \}
171
172       is
173
174           { The sum of 1 and 2 is 3  }
175
176       If you have an unmatched brace, "Text::Template" will return a failure
177       code and a warning about where the problem is.  Backslashes that do not
178       precede a brace are passed through unchanged.  If you have a template
179       like this:
180
181           { "String that ends in a newline.\n" }
182
183       The backslash inside the string is passed through to Perl unchanged, so
184       the "\n" really does turn into a newline.  See the note at the end for
185       details about the way backslashes work.  Backslash processing is not
186       done when you specify alternative delimiters with the "DELIMITERS"
187       option.  (See "Alternative Delimiters", below.)
188
189       Each program fragment should be a sequence of Perl statements, which
190       are evaluated the usual way.  The result of the last statement executed
191       will be evaluated in scalar context; the result of this statement is a
192       string, which is interpolated into the template in place of the program
193       fragment itself.
194
195       The fragments are evaluated in order, and side effects from earlier
196       fragments will persist into later fragments:
197
198           {$x = @things; ''}The Lord High Chamberlain has gotten {$x}
199           things for me this year.
200           { $diff = $x - 17;
201             $more = 'more'
202             if ($diff == 0) {
203               $diff = 'no';
204             } elsif ($diff < 0) {
205               $more = 'fewer';
206             }
207             '';
208           }
209           That is {$diff} {$more} than he gave me last year.
210
211       The value of $x set in the first line will persist into the next
212       fragment that begins on the third line, and the values of $diff and
213       $more set in the second fragment will persist and be interpolated into
214       the last line.  The output will look something like this:
215
216           The Lord High Chamberlain has gotten 42
217           things for me this year.
218
219           That is 25 more than he gave me last year.
220
221       That is all the syntax there is.
222
223   The $OUT variable
224       There is one special trick you can play in a template.  Here is the
225       motivation for it:  Suppose you are going to pass an array, @items,
226       into the template, and you want the template to generate a bulleted
227       list with a header, like this:
228
229           Here is a list of the things I have got for you since 1907:
230             * Ivory
231             * Apes
232             * Peacocks
233             * ...
234
235       One way to do it is with a template like this:
236
237           Here is a list of the things I have got for you since 1907:
238           { my $blist = '';
239             foreach $i (@items) {
240                 $blist .= qq{  * $i\n};
241             }
242             $blist;
243           }
244
245       Here we construct the list in a variable called $blist, which we return
246       at the end.  This is a little cumbersome.  There is a shortcut.
247
248       Inside of templates, there is a special variable called $OUT.  Anything
249       you append to this variable will appear in the output of the template.
250       Also, if you use $OUT in a program fragment, the normal behavior, of
251       replacing the fragment with its return value, is disabled; instead the
252       fragment is replaced with the value of $OUT.  This means that you can
253       write the template above like this:
254
255           Here is a list of the things I have got for you since 1907:
256           { foreach $i (@items) {
257               $OUT .= "  * $i\n";
258             }
259           }
260
261       $OUT is reinitialized to the empty string at the start of each program
262       fragment.  It is private to "Text::Template", so you can't use a
263       variable named $OUT in your template without invoking the special
264       behavior.
265
266   General Remarks
267       All "Text::Template" functions return "undef" on failure, and set the
268       variable $Text::Template::ERROR to contain an explanation of what went
269       wrong.  For example, if you try to create a template from a file that
270       does not exist, $Text::Template::ERROR will contain something like:
271
272           Couldn't open file xyz.tmpl: No such file or directory
273
274   "new"
275           $template = Text::Template->new( TYPE => ..., SOURCE => ... );
276
277       This creates and returns a new template object.  "new" returns "undef"
278       and sets $Text::Template::ERROR if it can't create the template object.
279       "SOURCE" says where the template source code will come from.  "TYPE"
280       says what kind of object the source is.
281
282       The most common type of source is a file:
283
284           Text::Template->new( TYPE => 'FILE', SOURCE => $filename );
285
286       This reads the template from the specified file.  The filename is
287       opened with the Perl "open" command, so it can be a pipe or anything
288       else that makes sense with "open".
289
290       The "TYPE" can also be "STRING", in which case the "SOURCE" should be a
291       string:
292
293           Text::Template->new( TYPE => 'STRING',
294                                SOURCE => "This is the actual template!" );
295
296       The "TYPE" can be "ARRAY", in which case the source should be a
297       reference to an array of strings.  The concatenation of these strings
298       is the template:
299
300           Text::Template->new( TYPE => 'ARRAY',
301                                    SOURCE => [ "This is ", "the actual",
302                                                " template!",
303                                              ]
304                              );
305
306       The "TYPE" can be FILEHANDLE, in which case the source should be an
307       open filehandle (such as you got from the "FileHandle" or "IO::*"
308       packages, or a glob, or a reference to a glob).  In this case
309       "Text::Template" will read the text from the filehandle up to end-of-
310       file, and that text is the template:
311
312           # Read template source code from STDIN:
313           Text::Template->new ( TYPE => 'FILEHANDLE',
314                                 SOURCE => \*STDIN  );
315
316       If you omit the "TYPE" attribute, it's taken to be "FILE".  "SOURCE" is
317       required.  If you omit it, the program will abort.
318
319       The words "TYPE" and "SOURCE" can be spelled any of the following ways:
320
321           TYPE     SOURCE
322           Type     Source
323           type     source
324           -TYPE    -SOURCE
325           -Type    -Source
326           -type    -source
327
328       Pick a style you like and stick with it.
329
330       "DELIMITERS"
331           You may also add a "DELIMITERS" option.  If this option is present,
332           its value should be a reference to an array of two strings.  The
333           first string is the string that signals the beginning of each
334           program fragment, and the second string is the string that signals
335           the end of each program fragment.  See "Alternative Delimiters",
336           below.
337
338       "ENCODING"
339           You may also add a "ENCODING" option.  If this option is present,
340           and the "SOURCE" is a "FILE", then the data will be decoded from
341           the given encoding using the Encode module.  You can use any
342           encoding that Encode recognizes.  E.g.:
343
344               Text::Template->new(
345                   TYPE     => 'FILE',
346                   ENCODING => 'UTF-8',
347                   SOURCE   => 'xyz.tmpl');
348
349       "UNTAINT"
350           If your program is running in taint mode, you may have problems if
351           your templates are stored in files.  Data read from files is
352           considered 'untrustworthy', and taint mode will not allow you to
353           evaluate the Perl code in the file.  (It is afraid that a malicious
354           person might have tampered with the file.)
355
356           In some environments, however, local files are trustworthy.  You
357           can tell "Text::Template" that a certain file is trustworthy by
358           supplying "UNTAINT => 1" in the call to "new".  This will tell
359           "Text::Template" to disable taint checks on template code that has
360           come from a file, as long as the filename itself is considered
361           trustworthy.  It will also disable taint checks on template code
362           that comes from a filehandle.  When used with "TYPE => 'string'" or
363           "TYPE => 'array'", it has no effect.
364
365           See perlsec for more complete information about tainting.
366
367           Thanks to Steve Palincsar, Gerard Vreeswijk, and Dr. Christoph
368           Baehr for help with this feature.
369
370       "PREPEND"
371           This option is passed along to the "fill_in" call unless it is
372           overridden in the arguments to "fill_in".  See ""PREPEND" feature
373           and using "strict" in templates" below.
374
375       "BROKEN"
376           This option is passed along to the "fill_in" call unless it is
377           overridden in the arguments to "fill_in".  See "BROKEN" below.
378
379   "compile"
380           $template->compile()
381
382       Loads all the template text from the template's source, parses and
383       compiles it.  If successful, returns true; otherwise returns false and
384       sets $Text::Template::ERROR.  If the template is already compiled, it
385       returns true and does nothing.
386
387       You don't usually need to invoke this function, because "fill_in" (see
388       below) compiles the template if it isn't compiled already.
389
390       If there is an argument to this function, it must be a reference to an
391       array containing alternative delimiter strings.  See "Alternative
392       Delimiters", below.
393
394   "fill_in"
395           $template->fill_in(OPTIONS);
396
397       Fills in a template.  Returns the resulting text if successful.
398       Otherwise, returns "undef"  and sets $Text::Template::ERROR.
399
400       The OPTIONS are a hash, or a list of key-value pairs.  You can write
401       the key names in any of the six usual styles as above; this means that
402       where this manual says "PACKAGE" (for example) you can actually use any
403       of
404
405           PACKAGE Package package -PACKAGE -Package -package
406
407       Pick a style you like and stick with it.  The all-lowercase versions
408       may yield spurious warnings about
409
410           Ambiguous use of package => resolved to "package"
411
412       so you might like to avoid them and use the capitalized versions.
413
414       At present, there are eight legal options:  "PACKAGE", "BROKEN",
415       "BROKEN_ARG", "FILENAME", "SAFE", "HASH", "OUTPUT", and "DELIMITERS".
416
417       "PACKAGE"
418           "PACKAGE" specifies the name of a package in which the program
419           fragments should be evaluated.  The default is to use the package
420           from which "fill_in" was called.  For example, consider this
421           template:
422
423               The value of the variable x is {$x}.
424
425           If you use "$template->fill_in(PACKAGE => 'R')" , then the $x in
426           the template is actually replaced with the value of $R::x.  If you
427           omit the "PACKAGE" option, $x will be replaced with the value of
428           the $x variable in the package that actually called "fill_in".
429
430           You should almost always use "PACKAGE".  If you don't, and your
431           template makes changes to variables, those changes will be
432           propagated back into the main program.  Evaluating the template in
433           a private package helps prevent this.  The template can still
434           modify variables in your program if it wants to, but it will have
435           to do so explicitly.  See the section at the end on `Security'.
436
437           Here's an example of using "PACKAGE":
438
439               Your Royal Highness,
440
441               Enclosed please find a list of things I have gotten
442               for you since 1907:
443
444               { foreach $item (@items) {
445                       $item_no++;
446                   $OUT .= " $item_no. \u$item\n";
447                 }
448               }
449
450               Signed,
451               Lord High Chamberlain
452
453           We want to pass in an array which will be assigned to the array
454           @items.  Here's how to do that:
455
456               @items = ('ivory', 'apes', 'peacocks', );
457               $template->fill_in();
458
459           This is not very safe.  The reason this isn't as safe is that if
460           you had a variable named $item_no in scope in your program at the
461           point you called "fill_in", its value would be clobbered by the act
462           of filling out the template.  The problem is the same as if you had
463           written a subroutine that used those variables in the same way that
464           the template does.  ($OUT is special in templates and is always
465           safe.)
466
467           One solution to this is to make the $item_no variable private to
468           the template by declaring it with "my".  If the template does this,
469           you are safe.
470
471           But if you use the "PACKAGE" option, you will probably be safe even
472           if the template does not declare its variables with "my":
473
474               @Q::items = ('ivory', 'apes', 'peacocks', );
475               $template->fill_in(PACKAGE => 'Q');
476
477           In this case the template will clobber the variable $Q::item_no,
478           which is not related to the one your program was using.
479
480           Templates cannot affect variables in the main program that are
481           declared with "my", unless you give the template references to
482           those variables.
483
484       "HASH"
485           You may not want to put the template variables into a package.
486           Packages can be hard to manage:  You can't copy them, for example.
487           "HASH" provides an alternative.
488
489           The value for "HASH" should be a reference to a hash that maps
490           variable names to values.  For example,
491
492               $template->fill_in(
493                   HASH => {
494                       recipient => "The King",
495                       items     => ['gold', 'frankincense', 'myrrh'],
496                       object    => \$self,
497                   }
498               );
499
500           will fill out the template and use "The King" as the value of
501           $recipient and the list of items as the value of @items.  Note that
502           we pass an array reference, but inside the template it appears as
503           an array.  In general, anything other than a simple string or
504           number should be passed by reference.
505
506           We also want to pass an object, which is in $self; note that we
507           pass a reference to the object, "\$self" instead.  Since we've
508           passed a reference to a scalar, inside the template the object
509           appears as $object.
510
511           The full details of how it works are a little involved, so you
512           might want to skip to the next section.
513
514           Suppose the key in the hash is key and the value is value.
515
516           ·   If the value is "undef", then any variables named $key, @key,
517               %key, etc., are undefined.
518
519           ·   If the value is a string or a number, then $key is set to that
520               value in the template.
521
522           ·   For anything else, you must pass a reference.
523
524               If the value is a reference to an array, then @key is set to
525               that array.  If the value is a reference to a hash, then %key
526               is set to that hash.  Similarly if value is any other kind of
527               reference.  This means that
528
529                   var => "foo"
530
531               and
532
533                   var => \"foo"
534
535               have almost exactly the same effect.  (The difference is that
536               in the former case, the value is copied, and in the latter case
537               it is aliased.)
538
539           ·   In particular, if you want the template to get an object or any
540               kind, you must pass a reference to it:
541
542                   $template->fill_in(HASH => { database_handle => \$dbh, ... });
543
544               If you do this, the template will have a variable
545               $database_handle which is the database handle object.  If you
546               leave out the "\", the template will have a hash
547               %database_handle, which exposes the internal structure of the
548               database handle object; you don't want that.
549
550           Normally, the way this works is by allocating a private package,
551           loading all the variables into the package, and then filling out
552           the template as if you had specified that package.  A new package
553           is allocated each time.  However, if you also use the "PACKAGE"
554           option, "Text::Template" loads the variables into the package you
555           specified, and they stay there after the call returns.  Subsequent
556           calls to "fill_in" that use the same package will pick up the
557           values you loaded in.
558
559           If the argument of "HASH" is a reference to an array instead of a
560           reference to a hash, then the array should contain a list of hashes
561           whose contents are loaded into the template package one after the
562           other.  You can use this feature if you want to combine several
563           sets of variables.  For example, one set of variables might be the
564           defaults for a fill-in form, and the second set might be the user
565           inputs, which override the defaults when they are present:
566
567               $template->fill_in(HASH => [\%defaults, \%user_input]);
568
569           You can also use this to set two variables with the same name:
570
571               $template->fill_in(
572                   HASH => [
573                       { v => "The King" },
574                       { v => [1,2,3] }
575                   ]
576               );
577
578           This sets $v to "The King" and @v to "(1,2,3)".
579
580       "BROKEN"
581           If any of the program fragments fails to compile or aborts for any
582           reason, and you have set the "BROKEN" option to a function
583           reference, "Text::Template" will invoke the function.  This
584           function is called the "BROKEN" function.  The "BROKEN" function
585           will tell "Text::Template" what to do next.
586
587           If the "BROKEN" function returns "undef", "Text::Template" will
588           immediately abort processing the template and return the text that
589           it has accumulated so far.  If your function does this, it should
590           set a flag that you can examine after "fill_in" returns so that you
591           can tell whether there was a premature return or not.
592
593           If the "BROKEN" function returns any other value, that value will
594           be interpolated into the template as if that value had been the
595           return value of the program fragment to begin with.  For example,
596           if the "BROKEN" function returns an error string, the error string
597           will be interpolated into the output of the template in place of
598           the program fragment that cased the error.
599
600           If you don't specify a "BROKEN" function, "Text::Template" supplies
601           a default one that returns something like
602
603               Program fragment delivered error ``Illegal division by 0 at
604               template line 37''
605
606           (Note that the format of this message has changed slightly since
607           version 1.31.)  The return value of the "BROKEN" function is
608           interpolated into the template at the place the error occurred, so
609           that this template:
610
611               (3+4)*5 = { 3+4)*5 }
612
613           yields this result:
614
615               (3+4)*5 = Program fragment delivered error ``syntax error at template line 1''
616
617           If you specify a value for the "BROKEN" attribute, it should be a
618           reference to a function that "fill_in" can call instead of the
619           default function.
620
621           "fill_in" will pass a hash to the "broken" function.  The hash will
622           have at least these three members:
623
624           "text"
625               The source code of the program fragment that failed
626
627           "error"
628               The text of the error message ($@) generated by eval.
629
630               The text has been modified to omit the trailing newline and to
631               include the name of the template file (if there was one).  The
632               line number counts from the beginning of the template, not from
633               the beginning of the failed program fragment.
634
635           "lineno"
636               The line number of the template at which the program fragment
637               began.
638
639           There may also be an "arg" member.  See "BROKEN_ARG", below
640
641       "BROKEN_ARG"
642           If you supply the "BROKEN_ARG" option to "fill_in", the value of
643           the option is passed to the "BROKEN" function whenever it is
644           called.  The default "BROKEN" function ignores the "BROKEN_ARG",
645           but you can write a custom "BROKEN" function that uses the
646           "BROKEN_ARG" to get more information about what went wrong.
647
648           The "BROKEN" function could also use the "BROKEN_ARG" as a
649           reference to store an error message or some other information that
650           it wants to communicate back to the caller.  For example:
651
652               $error = '';
653
654               sub my_broken {
655                  my %args = @_;
656                  my $err_ref = $args{arg};
657                  ...
658                  $$err_ref = "Some error message";
659                  return undef;
660               }
661
662               $template->fill_in(
663                   BROKEN     => \&my_broken,
664                   BROKEN_ARG => \$error
665               );
666
667               if ($error) {
668                 die "It didn't work: $error";
669               }
670
671           If one of the program fragments in the template fails, it will call
672           the "BROKEN" function, "my_broken", and pass it the "BROKEN_ARG",
673           which is a reference to $error.  "my_broken" can store an error
674           message into $error this way.  Then the function that called
675           "fill_in" can see if "my_broken" has left an error message for it
676           to find, and proceed accordingly.
677
678       "FILENAME"
679           If you give "fill_in" a "FILENAME" option, then this is the file
680           name that you loaded the template source from.  This only affects
681           the error message that is given for template errors.  If you loaded
682           the template from "foo.txt" for example, and pass "foo.txt" as the
683           "FILENAME" parameter, errors will look like "... at foo.txt line N"
684           rather than "... at template line N".
685
686           Note that this does NOT have anything to do with loading a template
687           from the given filename.  See "fill_in_file()" for that.
688
689           For example:
690
691            my $template = Text::Template->new(
692                TYPE   => 'string',
693                SOURCE => 'The value is {1/0}');
694
695            $template->fill_in(FILENAME => 'foo.txt') or die $Text::Template::ERROR;
696
697           will die with an error that contains
698
699            Illegal division by zero at at foo.txt line 1
700
701       "SAFE"
702           If you give "fill_in" a "SAFE" option, its value should be a safe
703           compartment object from the "Safe" package.  All evaluation of
704           program fragments will be performed in this compartment.  See Safe
705           for full details about such compartments and how to restrict the
706           operations that can be performed in them.
707
708           If you use the "PACKAGE" option with "SAFE", the package you
709           specify will be placed into the safe compartment and evaluation
710           will take place in that package as usual.
711
712           If not, "SAFE" operation is a little different from the default.
713           Usually, if you don't specify a package, evaluation of program
714           fragments occurs in the package from which the template was
715           invoked.  But in "SAFE" mode the evaluation occurs inside the safe
716           compartment and cannot affect the calling package.  Normally, if
717           you use "HASH" without "PACKAGE", the hash variables are imported
718           into a private, one-use-only package.  But if you use "HASH" and
719           "SAFE" together without "PACKAGE", the hash variables will just be
720           loaded into the root namespace of the "Safe" compartment.
721
722       "OUTPUT"
723           If your template is going to generate a lot of text that you are
724           just going to print out again anyway,  you can save memory by
725           having "Text::Template" print out the text as it is generated
726           instead of making it into a big string and returning the string.
727           If you supply the "OUTPUT" option to "fill_in", the value should be
728           a filehandle.  The generated text will be printed to this
729           filehandle as it is constructed.  For example:
730
731               $template->fill_in(OUTPUT => \*STDOUT, ...);
732
733           fills in the $template as usual, but the results are immediately
734           printed to STDOUT.  This may result in the output appearing more
735           quickly than it would have otherwise.
736
737           If you use "OUTPUT", the return value from "fill_in" is still true
738           on success and false on failure, but the complete text is not
739           returned to the caller.
740
741       "PREPEND"
742           You can have some Perl code prepended automatically to the
743           beginning of every program fragment.  See ""PREPEND" feature and
744           using "strict" in templates" below.
745
746       "DELIMITERS"
747           If this option is present, its value should be a reference to a
748           list of two strings.  The first string is the string that signals
749           the beginning of each program fragment, and the second string is
750           the string that signals the end of each program fragment.  See
751           "Alternative Delimiters", below.
752
753           If you specify "DELIMITERS" in the call to "fill_in", they override
754           any delimiters you set when you created the template object with
755           "new".
756

Convenience Functions

758   "fill_this_in"
759       The basic way to fill in a template is to create a template object and
760       then call "fill_in" on it.   This is useful if you want to fill in the
761       same template more than once.
762
763       In some programs, this can be cumbersome.  "fill_this_in" accepts a
764       string, which contains the template, and a list of options, which are
765       passed to "fill_in" as above.  It constructs the template object for
766       you, fills it in as specified, and returns the results.  It returns
767       "undef" and sets $Text::Template::ERROR if it couldn't generate any
768       results.
769
770       An example:
771
772           $Q::name = 'Donald';
773           $Q::amount = 141.61;
774           $Q::part = 'hyoid bone';
775
776           $text = Text::Template->fill_this_in( <<'EOM', PACKAGE => Q);
777           Dear {$name},
778           You owe me \\${sprintf('%.2f', $amount)}.
779           Pay or I will break your {$part}.
780               Love,
781               Grand Vizopteryx of Irkutsk.
782           EOM
783
784       Notice how we included the template in-line in the program by using a
785       `here document' with the "<<" notation.
786
787       "fill_this_in" is a deprecated feature.  It is only here for backwards
788       compatibility, and may be removed in some far-future version in
789       "Text::Template".  You should use "fill_in_string" instead.  It is
790       described in the next section.
791
792   "fill_in_string"
793       It is stupid that "fill_this_in" is a class method.  It should have
794       been just an imported function, so that you could omit the
795       "Text::Template->" in the example above.  But I made the mistake four
796       years ago and it is too late to change it.
797
798       "fill_in_string" is exactly like "fill_this_in" except that it is not a
799       method and you can omit the "Text::Template->" and just say
800
801           print fill_in_string(<<'EOM', ...);
802           Dear {$name},
803             ...
804           EOM
805
806       To use "fill_in_string", you need to say
807
808           use Text::Template 'fill_in_string';
809
810       at the top of your program.   You should probably use "fill_in_string"
811       instead of "fill_this_in".
812
813   "fill_in_file"
814       If you import "fill_in_file", you can say
815
816           $text = fill_in_file(filename, ...);
817
818       The "..." are passed to "fill_in" as above.  The filename is the name
819       of the file that contains the template you want to fill in.  It returns
820       the result text. or "undef", as usual.
821
822       If you are going to fill in the same file more than once in the same
823       program you should use the longer "new" / "fill_in" sequence instead.
824       It will be a lot faster because it only has to read and parse the file
825       once.
826
827   Including files into templates
828       People always ask for this.  ``Why don't you have an include
829       function?'' they want to know.  The short answer is this is Perl, and
830       Perl already has an include function.  If you want it, you can just put
831
832           {qx{cat filename}}
833
834       into your template.  Voilà.
835
836       If you don't want to use "cat", you can write a little four-line
837       function that opens a file and dumps out its contents, and call it from
838       the template.  I wrote one for you.  In the template, you can say
839
840           {Text::Template::_load_text(filename)}
841
842       If that is too verbose, here is a trick.  Suppose the template package
843       that you are going to be mentioning in the "fill_in" call is package
844       "Q".  Then in the main program, write
845
846           *Q::include = \&Text::Template::_load_text;
847
848       This imports the "_load_text" function into package "Q" with the name
849       "include".  From then on, any template that you fill in with package
850       "Q" can say
851
852           {include(filename)}
853
854       to insert the text from the named file at that point.  If you are using
855       the "HASH" option instead, just put "include =>
856       \&Text::Template::_load_text" into the hash instead of importing it
857       explicitly.
858
859       Suppose you don't want to insert a plain text file, but rather you want
860       to include one template within another?  Just use "fill_in_file" in the
861       template itself:
862
863           {Text::Template::fill_in_file(filename)}
864
865       You can do the same importing trick if this is too much to type.
866

Miscellaneous

868   "my" variables
869       People are frequently surprised when this doesn't work:
870
871           my $recipient = 'The King';
872           my $text = fill_in_file('formletter.tmpl');
873
874       The text "The King" doesn't get into the form letter.  Why not?
875       Because $recipient is a "my" variable, and the whole point of "my"
876       variables is that they're private and inaccessible except in the scope
877       in which they're declared.  The template is not part of that scope, so
878       the template can't see $recipient.
879
880       If that's not the behavior you want, don't use "my".  "my" means a
881       private variable, and in this case you don't want the variable to be
882       private.  Put the variables into package variables in some other
883       package, and use the "PACKAGE" option to "fill_in":
884
885           $Q::recipient = $recipient;
886           my $text = fill_in_file('formletter.tmpl', PACKAGE => 'Q');
887
888       or pass the names and values in a hash with the "HASH" option:
889
890           my $text = fill_in_file('formletter.tmpl', HASH => { recipient => $recipient });
891
892   Security Matters
893       All variables are evaluated in the package you specify with the
894       "PACKAGE" option of "fill_in".  if you use this option, and if your
895       templates don't do anything egregiously stupid, you won't have to worry
896       that evaluation of the little programs will creep out into the rest of
897       your program and wreck something.
898
899       Nevertheless, there's really no way (except with "Safe") to protect
900       against a template that says
901
902           { $Important::Secret::Security::Enable = 0;
903             # Disable security checks in this program
904           }
905
906       or
907
908           { $/ = "ho ho ho";   # Sabotage future uses of <FH>.
909             # $/ is always a global variable
910           }
911
912       or even
913
914           { system("rm -rf /") }
915
916       so don't go filling in templates unless you're sure you know what's in
917       them.  If you're worried, or you can't trust the person who wrote the
918       template, use the "SAFE" option.
919
920       A final warning: program fragments run a small risk of accidentally
921       clobbering local variables in the "fill_in" function itself.  These
922       variables all have names that begin with $fi_, so if you stay away from
923       those names you'll be safe.  (Of course, if you're a real wizard you
924       can tamper with them deliberately for exciting effects; this is
925       actually how $OUT works.)  I can fix this, but it will make the package
926       slower to do it, so I would prefer not to.  If you are worried about
927       this, send me mail and I will show you what to do about it.
928
929   Alternative Delimiters
930       Lorenzo Valdettaro pointed out that if you are using "Text::Template"
931       to generate TeX output, the choice of braces as the program fragment
932       delimiters makes you suffer suffer suffer.  Starting in version 1.20,
933       you can change the choice of delimiters to something other than curly
934       braces.
935
936       In either the "new()" call or the "fill_in()" call, you can specify an
937       alternative set of delimiters with the "DELIMITERS" option.  For
938       example, if you would like code fragments to be delimited by "[@--" and
939       "--@]" instead of "{" and "}", use
940
941           ... DELIMITERS => [ '[@--', '--@]' ], ...
942
943       Note that these delimiters are literal strings, not regexes.  (I tried
944       for regexes, but it complicates the lexical analysis too much.)  Note
945       also that "DELIMITERS" disables the special meaning of the backslash,
946       so if you want to include the delimiters in the literal text of your
947       template file, you are out of luck---it is up to you to choose
948       delimiters that do not conflict with what you are doing.  The delimiter
949       strings may still appear inside of program fragments as long as they
950       nest properly.  This means that if for some reason you absolutely must
951       have a program fragment that mentions one of the delimiters, like this:
952
953           [@--
954               print "Oh no, a delimiter: --@]\n"
955           --@]
956
957       you may be able to make it work by doing this instead:
958
959           [@--
960               # Fake matching delimiter in a comment: [@--
961               print "Oh no, a delimiter: --@]\n"
962           --@]
963
964       It may be safer to choose delimiters that begin with a newline
965       character.
966
967       Because the parsing of templates is simplified by the absence of
968       backslash escapes, using alternative "DELIMITERS" may speed up the
969       parsing process by 20-25%.  This shows that my original choice of "{"
970       and "}" was very bad.
971
972   "PREPEND" feature and using "strict" in templates
973       Suppose you would like to use "strict" in your templates to detect
974       undeclared variables and the like.  But each code fragment is a
975       separate lexical scope, so you have to turn on "strict" at the top of
976       each and every code fragment:
977
978           { use strict;
979             use vars '$foo';
980             $foo = 14;
981             ...
982           }
983
984           ...
985
986           { # we forgot to put `use strict' here
987             my $result = $boo + 12;    # $boo is misspelled and should be $foo
988             # No error is raised on `$boo'
989           }
990
991       Because we didn't put "use strict" at the top of the second fragment,
992       it was only active in the first fragment, and we didn't get any
993       "strict" checking in the second fragment.  Then we misspelled $foo and
994       the error wasn't caught.
995
996       "Text::Template" version 1.22 and higher has a new feature to make this
997       easier.  You can specify that any text at all be automatically added to
998       the beginning of each program fragment.
999
1000       When you make a call to "fill_in", you can specify a
1001
1002           PREPEND => 'some perl statements here'
1003
1004       option; the statements will be prepended to each program fragment for
1005       that one call only.  Suppose that the "fill_in" call included a
1006
1007           PREPEND => 'use strict;'
1008
1009       option, and that the template looked like this:
1010
1011           { use vars '$foo';
1012             $foo = 14;
1013             ...
1014           }
1015
1016           ...
1017
1018           { my $result = $boo + 12;    # $boo is misspelled and should be $foo
1019             ...
1020           }
1021
1022       The code in the second fragment would fail, because $boo has not been
1023       declared.  "use strict" was implied, even though you did not write it
1024       explicitly, because the "PREPEND" option added it for you
1025       automatically.
1026
1027       There are three other ways to do this.  At the time you create the
1028       template object with "new", you can also supply a "PREPEND" option, in
1029       which case the statements will be prepended each time you fill in that
1030       template.  If the "fill_in" call has its own "PREPEND" option, this
1031       overrides the one specified at the time you created the template.
1032       Finally, you can make the class method call
1033
1034           Text::Template->always_prepend('perl statements');
1035
1036       If you do this, then call calls to "fill_in" for any template will
1037       attach the perl statements to the beginning of each program fragment,
1038       except where overridden by "PREPEND" options to "new" or "fill_in".
1039
1040       An alternative to adding "use strict;" to the PREPEND option, you can
1041       pass STRICT => 1 to fill_in when also passing the HASH option.
1042
1043       Suppose that the "fill_in" call included both
1044
1045           HASH   => {$foo => ''} and
1046           STRICT => 1
1047
1048       options, and that the template looked like this:
1049
1050           {
1051             $foo = 14;
1052             ...
1053           }
1054
1055           ...
1056
1057           { my $result = $boo + 12;    # $boo is misspelled and should be $foo
1058             ...
1059           }
1060
1061       The code in the second fragment would fail, because $boo has not been
1062       declared. "use strict" was implied, even though you did not write it
1063       explicitly, because the "STRICT" option added it for you automatically.
1064       Any variable referenced in the template that is not in the "HASH"
1065       option will be an error.
1066
1067   Prepending in Derived Classes
1068       This section is technical, and you should skip it on the first few
1069       readings.
1070
1071       Normally there are three places that prepended text could come from.
1072       It could come from the "PREPEND" option in the "fill_in" call, from the
1073       "PREPEND" option in the "new" call that created the template object, or
1074       from the argument of the "always_prepend" call.  "Text::Template" looks
1075       for these three things in order and takes the first one that it finds.
1076
1077       In a subclass of "Text::Template", this last possibility is ambiguous.
1078       Suppose "S" is a subclass of "Text::Template".  Should
1079
1080           Text::Template->always_prepend(...);
1081
1082       affect objects in class "Derived"?  The answer is that you can have it
1083       either way.
1084
1085       The "always_prepend" value for "Text::Template" is normally stored in
1086       a hash variable named %GLOBAL_PREPEND under the key "Text::Template".
1087       When "Text::Template" looks to see what text to prepend, it first looks
1088       in the template object itself, and if not, it looks in
1089       $GLOBAL_PREPEND{class} where class is the class to which the template
1090       object belongs.  If it doesn't find any value, it looks in
1091       $GLOBAL_PREPEND{'Text::Template'}.  This means that objects in class
1092       "Derived" will be affected by
1093
1094           Text::Template->always_prepend(...);
1095
1096       unless there is also a call to
1097
1098           Derived->always_prepend(...);
1099
1100       So when you're designing your derived class, you can arrange to have
1101       your objects ignore "Text::Template::always_prepend" calls by simply
1102       putting "Derived->always_prepend('')" at the top of your module.
1103
1104       Of course, there is also a final escape hatch: Templates support a
1105       "prepend_text" that is used to look up the appropriate text to be
1106       prepended at "fill_in" time.  Your derived class can override this
1107       method to get an arbitrary effect.
1108
1109   JavaScript
1110       Jennifer D. St Clair asks:
1111
1112           > Most of my pages contain JavaScript and Stylesheets.
1113           > How do I change the template identifier?
1114
1115       Jennifer is worried about the braces in the JavaScript being taken as
1116       the delimiters of the Perl program fragments.  Of course, disaster will
1117       ensue when perl tries to evaluate these as if they were Perl programs.
1118       The best choice is to find some unambiguous delimiter strings that you
1119       can use in your template instead of curly braces, and then use the
1120       "DELIMITERS" option.  However, if you can't do this for some reason,
1121       there are  two easy workarounds:
1122
1123       1. You can put "\" in front of "{", "}", or "\" to remove its special
1124       meaning.  So, for example, instead of
1125
1126           if (br== "n3") {
1127               // etc.
1128           }
1129
1130       you can put
1131
1132           if (br== "n3") \{
1133               // etc.
1134           \}
1135
1136       and it'll come out of the template engine the way you want.
1137
1138       But here is another method that is probably better.  To see how it
1139       works, first consider what happens if you put this into a template:
1140
1141           { 'foo' }
1142
1143       Since it's in braces, it gets evaluated, and obviously, this is going
1144       to turn into
1145
1146           foo
1147
1148       So now here's the trick: In Perl, "q{...}" is the same as '...'.  So if
1149       we wrote
1150
1151           {q{foo}}
1152
1153       it would turn into
1154
1155           foo
1156
1157       So for your JavaScript, just write
1158
1159           {q{if (br== "n3") {
1160              // etc.
1161              }}
1162           }
1163
1164       and it'll come out as
1165
1166           if (br== "n3") {
1167               // etc.
1168           }
1169
1170       which is what you want.
1171
1172       head2 Shut Up!
1173
1174       People sometimes try to put an initialization section at the top of
1175       their templates, like this:
1176
1177           { ...
1178               $var = 17;
1179           }
1180
1181       Then they complain because there is a 17 at the top of the output that
1182       they didn't want to have there.
1183
1184       Remember that a program fragment is replaced with its own return value,
1185       and that in Perl the return value of a code block is the value of the
1186       last expression that was evaluated, which in this case is 17.  If it
1187       didn't do that, you wouldn't be able to write "{$recipient}" and have
1188       the recipient filled in.
1189
1190       To prevent the 17 from appearing in the output is very simple:
1191
1192           { ...
1193               $var = 17;
1194               '';
1195           }
1196
1197       Now the last expression evaluated yields the empty string, which is
1198       invisible.  If you don't like the way this looks, use
1199
1200           { ...
1201               $var = 17;
1202               ($SILENTLY);
1203           }
1204
1205       instead.  Presumably, $SILENTLY has no value, so nothing will be
1206       interpolated.  This is what is known as a `trick'.
1207
1208   Compatibility
1209       Every effort has been made to make this module compatible with older
1210       versions.  The only known exceptions follow:
1211
1212       The output format of the default "BROKEN" subroutine has changed twice,
1213       most recently between versions 1.31 and 1.40.
1214
1215       Starting in version 1.10, the $OUT variable is arrogated for a special
1216       meaning.  If you had templates before version 1.10 that happened to use
1217       a variable named $OUT, you will have to change them to use some other
1218       variable or all sorts of strangeness will result.
1219
1220       Between versions 0.1b and 1.00 the behavior of the \ metacharacter
1221       changed.  In 0.1b, \\ was special everywhere, and the template
1222       processor always replaced it with a single backslash before passing the
1223       code to Perl for evaluation.  The rule now is more complicated but
1224       probably more convenient.  See the section on backslash processing,
1225       below, for a full discussion.
1226
1227   Backslash Processing
1228       In "Text::Template" beta versions, the backslash was special whenever
1229       it appeared before a brace or another backslash.  That meant that while
1230       "{"\n"}" did indeed generate a newline, "{"\\"}" did not generate a
1231       backslash, because the code passed to Perl for evaluation was "\" which
1232       is a syntax error.  If you wanted a backslash, you would have had to
1233       write "{"\\\\"}".
1234
1235       In "Text::Template" versions 1.00 through 1.10, there was a bug:
1236       Backslash was special everywhere.  In these versions, "{"\n"}"
1237       generated the letter "n".
1238
1239       The bug has been corrected in version 1.11, but I did not go back to
1240       exactly the old rule, because I did not like the idea of having to
1241       write "{"\\\\"}" to get one backslash.  The rule is now more
1242       complicated to remember, but probably easier to use.  The rule is now:
1243       Backslashes are always passed to Perl unchanged unless they occur as
1244       part of a sequence like "\\\\\\{" or "\\\\\\}".  In these contexts,
1245       they are special; "\\" is replaced with "\", and "\{" and "\}" signal a
1246       literal brace.
1247
1248       Examples:
1249
1250           \{ foo \}
1251
1252       is not evaluated, because the "\" before the braces signals that they
1253       should be taken literally.  The result in the output looks like this:
1254
1255           { foo }
1256
1257       This is a syntax error:
1258
1259           { "foo}" }
1260
1261       because "Text::Template" thinks that the code ends at the first "}",
1262       and then gets upset when it sees the second one.  To make this work
1263       correctly, use
1264
1265           { "foo\}" }
1266
1267       This passes "foo}" to Perl for evaluation.  Note there's no "\" in the
1268       evaluated code.  If you really want a "\" in the evaluated code, use
1269
1270           { "foo\\\}" }
1271
1272       This passes "foo\}" to Perl for evaluation.
1273
1274       Starting with "Text::Template" version 1.20, backslash processing is
1275       disabled if you use the "DELIMITERS" option to specify alternative
1276       delimiter strings.
1277
1278   A short note about $Text::Template::ERROR
1279       In the past some people have fretted about `violating the package
1280       boundary' by examining a variable inside the "Text::Template" package.
1281       Don't feel this way.  $Text::Template::ERROR is part of the published,
1282       official interface to this package.  It is perfectly OK to inspect this
1283       variable.  The interface is not going to change.
1284
1285       If it really, really bothers you, you can import a function called
1286       "TTerror" that returns the current value of the $ERROR variable.  So
1287       you can say:
1288
1289           use Text::Template 'TTerror';
1290
1291           my $template = Text::Template->new(SOURCE => $filename);
1292           unless ($template) {
1293               my $err = TTerror;
1294               die "Couldn't make template: $err; aborting";
1295           }
1296
1297       I don't see what benefit this has over just doing this:
1298
1299           use Text::Template;
1300
1301           my $template = Text::Template->new(SOURCE => $filename)
1302               or die "Couldn't make template: $Text::Template::ERROR; aborting";
1303
1304       But if it makes you happy to do it that way, go ahead.
1305
1306   Sticky Widgets in Template Files
1307       The "CGI" module provides functions for `sticky widgets', which are
1308       form input controls that retain their values from one page to the next.
1309       Sometimes people want to know how to include these widgets into their
1310       template output.
1311
1312       It's totally straightforward.  Just call the "CGI" functions from
1313       inside the template:
1314
1315           { $q->checkbox_group(NAME      => 'toppings',
1316                                LINEBREAK => true,
1317                                COLUMNS   => 3,
1318                                VALUES    => \@toppings,
1319                               );
1320           }
1321
1322   Automatic preprocessing of program fragments
1323       It may be useful to preprocess the program fragments before they are
1324       evaluated.  See "Text::Template::Preprocess" for more details.
1325
1326   Automatic postprocessing of template hunks
1327       It may be useful to process hunks of output before they are appended to
1328       the result text.  For this, subclass and replace the
1329       "append_text_to_result" method.  It is passed a list of pairs with
1330       these entries:
1331
1332         handle - a filehandle to which to print the desired output
1333         out    - a ref to a string to which to append, to use if handle is not given
1334         text   - the text that will be appended
1335         type   - where the text came from: TEXT for literal text, PROG for code
1336

HISTORY

1338       Originally written by Mark Jason Dominus, Plover Systems (versions 0.01
1339       - 1.46)
1340
1341       Maintainership transferred to Michael Schout <mschout@cpan.org> in
1342       version 1.47
1343

THANKS

1345       Many thanks to the following people for offering support,
1346       encouragement, advice, bug reports, and all the other good stuff.
1347
1348       ·   Andrew G Wood
1349
1350       ·   Andy Wardley
1351
1352       ·   António Aragão
1353
1354       ·   Archie Warnock
1355
1356       ·   Bek Oberin
1357
1358       ·   Bob Dougherty
1359
1360       ·   Brian C. Shensky
1361
1362       ·   Chris Nandor
1363
1364       ·   Chris Wesley
1365
1366       ·   Chris.Brezil
1367
1368       ·   Daini Xie
1369
1370       ·   Dan Franklin
1371
1372       ·   Daniel LaLiberte
1373
1374       ·   David H. Adler
1375
1376       ·   David Marshall
1377
1378       ·   Dennis Taylor
1379
1380       ·   Donald L. Greer Jr.
1381
1382       ·   Dr. Frank Bucolo
1383
1384       ·   Fred Steinberg
1385
1386       ·   Gene Damon
1387
1388       ·   Hans Persson
1389
1390       ·   Hans Stoop
1391
1392       ·   Itamar Almeida de Carvalho
1393
1394       ·   James H. Thompson
1395
1396       ·   James Mastros
1397
1398       ·   Jarko Hietaniemi
1399
1400       ·   Jason Moore
1401
1402       ·   Jennifer D. St Clair
1403
1404       ·   Joel Appelbaum
1405
1406       ·   Joel Meulenberg
1407
1408       ·   Jonathan Roy
1409
1410       ·   Joseph Cheek
1411
1412       ·   Juan E. Camacho
1413
1414       ·   Kevin Atteson
1415
1416       ·   Kevin Madsen
1417
1418       ·   Klaus Arnhold
1419
1420       ·   Larry Virden
1421
1422       ·   Lieven Tomme
1423
1424       ·   Lorenzo Valdettaro
1425
1426       ·   Marek Grac
1427
1428       ·   Matt Womer
1429
1430       ·   Matt X. Hunter
1431
1432       ·   Michael G Schwern
1433
1434       ·   Michael J. Suzio
1435
1436       ·   Michaely Yeung
1437
1438       ·   Michelangelo Grigni
1439
1440       ·   Mike Brodhead
1441
1442       ·   Niklas Skoglund
1443
1444       ·   Randal L. Schwartz
1445
1446       ·   Reuven M. Lerner
1447
1448       ·   Robert M. Ioffe
1449
1450       ·   Ron Pero
1451
1452       ·   San Deng
1453
1454       ·   Sean Roehnelt
1455
1456       ·   Sergey Myasnikov
1457
1458       ·   Shabbir J. Safdar
1459
1460       ·   Shad Todd
1461
1462       ·   Steve Palincsar
1463
1464       ·   Tim Bunce
1465
1466       ·   Todd A. Green
1467
1468       ·   Tom Brown
1469
1470       ·   Tom Henry
1471
1472       ·   Tom Snee
1473
1474       ·   Trip Lilley
1475
1476       ·   Uwe Schneider
1477
1478       ·   Val Luck
1479
1480       ·   Yannis Livassof
1481
1482       ·   Yonat Sharon
1483
1484       ·   Zac Hansen
1485
1486       ·   gary at dls.net
1487
1488       Special thanks to:
1489
1490       Jonathan Roy
1491         for telling me how to do the "Safe" support (I spent two years
1492         worrying about it, and then Jonathan pointed out that it was
1493         trivial.)
1494
1495       Ranjit Bhatnagar
1496         for demanding less verbose fragments like they have in ASP, for
1497         helping me figure out the Right Thing, and, especially, for talking
1498         me out of adding any new syntax.  These discussions resulted in the
1499         $OUT feature.
1500
1501   Bugs and Caveats
1502       "my" variables in "fill_in" are still susceptible to being clobbered by
1503       template evaluation.  They all begin with "fi_", so avoid those names
1504       in your templates.
1505
1506       The line number information will be wrong if the template's lines are
1507       not terminated by "\n".  You should let me know if this is a problem.
1508       If you do, I will fix it.
1509
1510       The $OUT variable has a special meaning in templates, so you cannot use
1511       it as if it were a regular variable.
1512
1513       There are not quite enough tests in the test suite.
1514

SOURCE

1516       The development version is on github at
1517       <https://https://github.com/mschout/perl-text-template> and may be
1518       cloned from <git://https://github.com/mschout/perl-text-template.git>
1519

BUGS

1521       Please report any bugs or feature requests on the bugtracker website
1522       <https://github.com/mschout/perl-text-template/issues>
1523
1524       When submitting a bug or request, please include a test-file or a patch
1525       to an existing test-file that illustrates the bug or desired feature.
1526

AUTHOR

1528       Michael Schout <mschout@cpan.org>
1529
1531       This software is copyright (c) 2013 by Mark Jason Dominus
1532       <mjd@cpan.org>.
1533
1534       This is free software; you can redistribute it and/or modify it under
1535       the same terms as the Perl 5 programming language system itself.
1536
1537
1538
1539perl v5.28.2                      2019-02-25                 Text::Template(3)
Impressum