Changes

Jump to navigation Jump to search
1,783 bytes removed ,  00:03, 22 December 2013
Line 2: Line 2:  
== NAME ==
 
== NAME ==
 
  Text::Template - Expand template text with embedded Perl
 
  Text::Template - Expand template text with embedded Perl
 
+
In a root terminal you can do the command below if you want to display the up-to-date content
 +
perldoc Text::Template
 
== VERSION ==
 
== VERSION ==
   Line 9: Line 10:  
== SYNOPSIS ==
 
== SYNOPSIS ==
 
         use Text::Template;
 
         use Text::Template;
 
+
 
         $template = Text::Template->new(TYPE => ’FILE’,  SOURCE => ’filename.tmpl’);
 
         $template = Text::Template->new(TYPE => ’FILE’,  SOURCE => ’filename.tmpl’);
 
         $template = Text::Template->new(TYPE => ’ARRAY’, SOURCE => [ ... ] );
 
         $template = Text::Template->new(TYPE => ’ARRAY’, SOURCE => [ ... ] );
Line 15: Line 16:  
         $template = Text::Template->new(TYPE => ’STRING’, SOURCE => ’...’ );
 
         $template = Text::Template->new(TYPE => ’STRING’, SOURCE => ’...’ );
 
         $template = Text::Template->new(PREPEND => q{use strict;}, ...);
 
         $template = Text::Template->new(PREPEND => q{use strict;}, ...);
 
+
 
         # Use a different template file syntax:
 
         # Use a different template file syntax:
 
         $template = Text::Template->new(DELIMITERS => [$open, $close], ...);
 
         $template = Text::Template->new(DELIMITERS => [$open, $close], ...);
 
+
 
         $recipient = ’King’;
 
         $recipient = ’King’;
 
         $text = $template->fill_in();  # Replaces ‘{$recipient}’ with ‘King’
 
         $text = $template->fill_in();  # Replaces ‘{$recipient}’ with ‘King’
 
         print $text;
 
         print $text;
 
+
 
         $T::recipient = ’Josh’;
 
         $T::recipient = ’Josh’;
 
         $text = $template->fill_in(PACKAGE => T);
 
         $text = $template->fill_in(PACKAGE => T);
 
+
 
         # Pass many variables explicitly
 
         # Pass many variables explicitly
 
         $hash = { recipient => ’Abed-Nego’,
 
         $hash = { recipient => ’Abed-Nego’,
Line 36: Line 37:  
         # @friends is ( ’me’, ’you’ ),
 
         # @friends is ( ’me’, ’you’ ),
 
         # %enemies is ( loathsome => ..., fearsome => ... )
 
         # %enemies is ( loathsome => ..., fearsome => ... )
 
+
 
         # Call &callback in case of programming errors in template
 
         # Call &callback in case of programming errors in template
 
         $text = $template->fill_in(BROKEN => \&callback, BROKEN_ARG => $ref, ...);
 
         $text = $template->fill_in(BROKEN => \&callback, BROKEN_ARG => $ref, ...);
 
+
 
         # Evaluate program fragments in Safe compartment with restricted permissions
 
         # Evaluate program fragments in Safe compartment with restricted permissions
 
         $text = $template->fill_in(SAFE => $compartment, ...);
 
         $text = $template->fill_in(SAFE => $compartment, ...);
 
+
 
         # Print result text instead of returning it
 
         # Print result text instead of returning it
 
         $success = $template->fill_in(OUTPUT => \*FILEHANDLE, ...);
 
         $success = $template->fill_in(OUTPUT => \*FILEHANDLE, ...);
 
+
 
Parse template with different template file syntax:
 
Parse template with different template file syntax:
 
         $text = $template->fill_in(DELIMITERS => [$open, $close], ...);
 
         $text = $template->fill_in(DELIMITERS => [$open, $close], ...);
 
         # Note that this is *faster* than using the default delimiters
 
         # Note that this is *faster* than using the default delimiters
 
+
 
         # Prepend specified perl code to each fragment before evaluating:
 
         # Prepend specified perl code to each fragment before evaluating:
 
         $text = $template->fill_in(PREPEND => q{use strict ’vars’;}, ...);
 
         $text = $template->fill_in(PREPEND => q{use strict ’vars’;}, ...);
 
+
 
         use Text::Template ’fill_in_string’;
 
         use Text::Template ’fill_in_string’;
 
         $text = fill_in_string( <<EOM, PACKAGE => ’T’, ...);
 
         $text = fill_in_string( <<EOM, PACKAGE => ’T’, ...);
Line 59: Line 60:  
               Love,
 
               Love,
 
                 G.V.
 
                 G.V.
EOM
+
    EOM
 
+
 
         use Text::Template ’fill_in_file’;
 
         use Text::Template ’fill_in_file’;
 
         $text = fill_in_file($filename, ...);
 
         $text = fill_in_file($filename, ...);
 
+
 
         # All templates will always have ‘use strict vars’ attached to all fragments
 
         # All templates will always have ‘use strict vars’ attached to all fragments
 
         Text::Template->always_prepend(q{use strict ’vars’;});
 
         Text::Template->always_prepend(q{use strict ’vars’;});
Line 77: Line 78:     
               Dear {$title} {$lastname},
 
               Dear {$title} {$lastname},
 
+
 
               It has come to our attention that you are delinquent in your
 
               It has come to our attention that you are delinquent in your
 
               {$monthname[$last_paid_month]} payment.  Please remit
 
               {$monthname[$last_paid_month]} payment.  Please remit
 
               ${sprintf("%.2f", $amount)} immediately, or your patellae may
 
               ${sprintf("%.2f", $amount)} immediately, or your patellae may
 
               be needlessly endangered.
 
               be needlessly endangered.
 
+
 
                               Love,
 
                               Love,
 
+
 
                               Mark "Vizopteryx" Dominus
 
                               Mark "Vizopteryx" Dominus
   Line 90: Line 91:     
               Dear Mr. Gates,
 
               Dear Mr. Gates,
 
+
 
               It has come to our attention that you are delinquent in your
 
               It has come to our attention that you are delinquent in your
 
               February payment.  Please remit
 
               February payment.  Please remit
 
               $392.12 immediately, or your patellae may
 
               $392.12 immediately, or your patellae may
 
               be needlessly endangered.
 
               be needlessly endangered.
 
+
 
                               Love,
 
                               Love,
 
+
 
                               Mark "Vizopteryx" Dominus
 
                               Mark "Vizopteryx" Dominus
   Line 103: Line 104:     
               use Text::Template;
 
               use Text::Template;
 
+
 
               my $template = Text::Template->new(SOURCE => ’formletter.tmpl’)
 
               my $template = Text::Template->new(SOURCE => ’formletter.tmpl’)
 
                 or die "Couldn’t construct template: $Text::Template::ERROR";
 
                 or die "Couldn’t construct template: $Text::Template::ERROR";
 
+
 
               my @monthname = qw(January February March April May June
 
               my @monthname = qw(January February March April May June
 
                                   July August September October November December);
 
                                   July August September October November December);
Line 116: Line 117:  
                           monthname => \@monthname,
 
                           monthname => \@monthname,
 
                           );
 
                           );
 
+
 
               my $result = $template->fill_in(HASH => \%vars);
 
               my $result = $template->fill_in(HASH => \%vars);
 
+
 
               if (defined $result) { print $result }
 
               if (defined $result) { print $result }
 
               else { die "Couldn’t fill in template: $Text::Template::ERROR" }
 
               else { die "Couldn’t fill in template: $Text::Template::ERROR" }
Line 124: Line 125:  
=== Philosophy ===
 
=== Philosophy ===
   −
When people make a template module like this one, they almost always start by inventing a special syntax for substitutions.  For example, they build it so that a string like "%%VAR%%" is replaced with the value of $VAR.  Then they realize the need extra formatting, so they put in some special syntax for formatting.  Then they need a loop, so they invent a loop syntax.  Pretty soon they have a new little template language.
+
When people make a template module like this one, they almost always start by inventing a special syntax for substitutions.  For example, they build it so that a string like "%%VAR%%" is replaced with the value of $VAR.  Then they realize the need extra formatting, so they put in some special syntax for formatting.  Then they need a loop, so they invent a loop syntax.  Pretty soon they have a new little template language.<br />
This approach has two problems: First, their little language is crippled. If you need to do something the author hasn’t thought of, you lose.  Second: Who wants to learn another language?  You already know Perl, so why not use it?
+
 
 +
This approach has two problems: First, their little language is crippled. If you need to do something the author hasn’t thought of, you lose.  Second: Who wants to learn another language?  You already know Perl, so why not use it?<br />
 +
 
    
"Text::Template" templates are programmed in Perl.  You embed Perl code in your template, with "{" at the beginning and "}" at the end.  If you want a variable interpolated, you write it the way you would in Perl. If you need to make a loop, you can use any of the Perl loop constructions.  All the Perl built-in functions are available.
 
"Text::Template" templates are programmed in Perl.  You embed Perl code in your template, with "{" at the beginning and "}" at the end.  If you want a variable interpolated, you write it the way you would in Perl. If you need to make a loop, you can use any of the Perl loop constructions.  All the Perl built-in functions are available.
Line 168: Line 171:  
               The Lord High Chamberlain has gotten 42
 
               The Lord High Chamberlain has gotten 42
 
               things for me this year.
 
               things for me this year.
 
+
 
               That is 25 more than he gave me last year.
 
               That is 25 more than he gave me last year.
   Line 219: Line 222:  
               new Text::Template ( TYPE => ’FILE’, SOURCE => $filename );
 
               new Text::Template ( TYPE => ’FILE’, SOURCE => $filename );
   −
This reads the template from the specified file.  The filename is opened with the Perl "open" command, so it can be a pipe or anything else that makes sense with "open". The "TYPE" can also be "STRING", in which case the "SOURCE" should be a
+
This reads the template from the specified file.  The filename is opened with the Perl "open" command, so it can be a pipe or anything else that makes sense with "open". The "TYPE" can also be "STRING", in which case the "SOURCE" should be a string:
      string:
      
               new Text::Template ( TYPE => ’STRING’,
 
               new Text::Template ( TYPE => ’STRING’,
Line 303: Line 305:     
                   Your Royal Highness,
 
                   Your Royal Highness,
 
+
 
                   Enclosed please find a list of things I have gotten
 
                   Enclosed please find a list of things I have gotten
 
                   for you since 1907:
 
                   for you since 1907:
 
+
 
                   { foreach $item (@items) {
 
                   { foreach $item (@items) {
 
                       $item_no++;
 
                       $item_no++;
Line 312: Line 314:  
                     }
 
                     }
 
                   }
 
                   }
 
+
 
                   Signed,
 
                   Signed,
 
                   Lord High Chamberlain
 
                   Lord High Chamberlain
 
+
 
We want to pass in an array which will be assigned to the array @items.  Here’s how to do that:
 
We want to pass in an array which will be assigned to the array @items.  Here’s how to do that:
   Line 422: Line 424:  
The "BROKEN" function could also use the "BROKEN_ARG" as a reference to store an error message or some other information that it wants to communicate back to the caller.  For example:
 
The "BROKEN" function could also use the "BROKEN_ARG" as a reference to store an error message or some other information that it wants to communicate back to the caller.  For example:
 
                 $error = ’’;
 
                 $error = ’’;
 
+
 
                   sub my_broken {
 
                   sub my_broken {
 
                       my %args = @_;
 
                       my %args = @_;
Line 430: Line 432:  
                       return undef;
 
                       return undef;
 
                   }
 
                   }
 
+
 
                   $template->fill_in(BROKEN => \&my_broken,
 
                   $template->fill_in(BROKEN => \&my_broken,
 
                                       BROKEN_ARG => \$error,
 
                                       BROKEN_ARG => \$error,
 
                                     );
 
                                     );
 
+
 
                   if ($error) {
 
                   if ($error) {
 
                     die "It didn’t work: $error";
 
                     die "It didn’t work: $error";
Line 465: Line 467:  
If you specify "DELIMITERS" in the call to "fill_in", they override any delimiters you set when you created the template object with "new".
 
If you specify "DELIMITERS" in the call to "fill_in", they override any delimiters you set when you created the template object with "new".
   −
Convenience Functions
+
==== Convenience Functions ====
      "fill_this_in"
+
===== "fill_this_in" =====
   −
      The basic way to fill in a template is to create a template object and
+
The basic way to fill in a template is to create a template object and then call "fill_in" on it.  This is useful if you want to fill in the same template more than once.
      then call "fill_in" on it.  This is useful if you want to fill in the
  −
      same template more than once.
     −
      In some programs, this can be cumbersome.  "fill_this_in" accepts a
+
In some programs, this can be cumbersome.  "fill_this_in" accepts a string, which contains the template, and a list of options, which are passed to "fill_in" as above.  It constructs the template object for you, fills it in as specified, and returns the results.  It returns "undef" and sets $Text::Template::ERROR if it couldn’t generate any results.
      string, which contains the template, and a list of options, which are
  −
      passed to "fill_in" as above.  It constructs the template object for
  −
      you, fills it in as specified, and returns the results.  It returns
  −
      "undef" and sets $Text::Template::ERROR if it couldn’t generate any
  −
      results.
     −
      An example:
+
An example:
    
               $Q::name = ’Donald’;
 
               $Q::name = ’Donald’;
 
               $Q::amount = 141.61;
 
               $Q::amount = 141.61;
 
               $Q::part = ’hyoid bone’;
 
               $Q::part = ’hyoid bone’;
 
+
 
               $text = Text::Template->fill_this_in( <<’EOM’, PACKAGE => Q);
 
               $text = Text::Template->fill_this_in( <<’EOM’, PACKAGE => Q);
 
               Dear {$name},
 
               Dear {$name},
Line 493: Line 488:  
               EOM
 
               EOM
   −
      Notice how we included the template in-line in the program by using a
+
Notice how we included the template in-line in the program by using a ‘here document’ with the "<<" notation.
      ‘here document’ with the "<<" notation.
     −
      "fill_this_in" is a deprecated feature.  It is only here for backwards
+
"fill_this_in" is a deprecated feature.  It is only here for backwards compatibility, and may be removed in some far-future version in "Text::Template".  You should use "fill_in_string" instead.  It is described in the next section.
      compatibility, and may be removed in some far-future version in
  −
      "Text::Template".  You should use "fill_in_string" instead.  It is
  −
      described in the next section.
  −
    "fill_in_string"
     −
      It is stupid that "fill_this_in" is a class method.  It should have
+
===== "fill_in_string" =====
      been just an imported function, so that you could omit the "Text::Tem-
  −
      plate->" in the example above.  But I made the mistake four years ago
  −
      and it is too late to change it.
     −
      "fill_in_string" is exactly like "fill_this_in" except that it is not a
+
It is stupid that "fill_this_in" is a class method.  It should have been just an imported function, so that you could omit the "Text::Template->" in the example above.  But I made the mistake four years ago and it is too late to change it.
      method and you can omit the "Text::Template->" and just say
+
 
 +
"fill_in_string" is exactly like "fill_this_in" except that it is not a method and you can omit the "Text::Template->" and just say
    
               print fill_in_string(<<’EOM’, ...);
 
               print fill_in_string(<<’EOM’, ...);
Line 515: Line 503:  
               EOM
 
               EOM
   −
      To use "fill_in_string", you need to say
+
To use "fill_in_string", you need to say
    
               use Text::Template ’fill_in_string’;
 
               use Text::Template ’fill_in_string’;
   −
      at the top of your program.  You should probably use "fill_in_string"
+
at the top of your program.  You should probably use "fill_in_string" instead of "fill_this_in".
      instead of "fill_this_in".
      
       "fill_in_file"
 
       "fill_in_file"
 
+
If you import "fill_in_file", you can say
      If you import "fill_in_file", you can say
      
               $text = fill_in_file(filename, ...);
 
               $text = fill_in_file(filename, ...);
   −
      The "..." are passed to "fill_in" as above.  The filename is the name
+
The "..." are passed to "fill_in" as above.  The filename is the name of the file that contains the template you want to fill in.  It returns the result text. or "undef", as usual.
      of the file that contains the template you want to fill in.  It returns
  −
      the result text. or "undef", as usual.
     −
      If you are going to fill in the same file more than once in the same
+
If you are going to fill in the same file more than once in the same program you should use the longer "new" / "fill_in" sequence instead. It will be a lot faster because it only has to read and parse the file once.
      program you should use the longer "new" / "fill_in" sequence instead.
  −
      It will be a lot faster because it only has to read and parse the file
  −
      once.
     −
      Including files into templates
+
Including files into templates
   −
      People always ask for this.  ‘‘Why don’t you have an include func-
+
People always ask for this.  ‘‘Why don’t you have an include function?’’ they want to know.  The short answer is this is Perl, and Perl already has an include function.  If you want it, you can just put
      tion?’’ they want to know.  The short answer is this is Perl, and Perl
  −
      already has an include function.  If you want it, you can just put
      
               {qx{cat filename}}
 
               {qx{cat filename}}
   −
      into your template.  VoilA.
+
into your template.  VoilA.
  If you don’t want to use "cat", you can write a little four-line func-
+
 
      tion that opens a file and dumps out its contents, and call it from the
+
If you don’t want to use "cat", you can write a little four-line function that opens a file and dumps out its contents, and call it from the template.  I wrote one for you.  In the template, you can say
      template.  I wrote one for you.  In the template, you can say
      
               {Text::Template::_load_text(filename)}
 
               {Text::Template::_load_text(filename)}
   −
      If that is too verbose, here is a trick.  Suppose the template package
+
If that is too verbose, here is a trick.  Suppose the template package that you are going to be mentioning in the "fill_in" call is package "Q".  Then in the main program, write
      that you are going to be mentioning in the "fill_in" call is package
  −
      "Q".  Then in the main program, write
      
               *Q::include = \&Text::Template::_load_text;
 
               *Q::include = \&Text::Template::_load_text;
   −
      This imports the "_load_text" function into package "Q" with the name
+
This imports the "_load_text" function into package "Q" with the name "include".  From then on, any template that you fill in with package "Q" can say
      "include".  From then on, any template that you fill in with package
  −
      "Q" can say
      
               {include(filename)}
 
               {include(filename)}
   −
      to insert the text from the named file at that point.  If you are using
+
to insert the text from the named file at that point.  If you are using the "HASH" option instead, just put "include => \&Text::Template::_load_text" into the hash instead of importing it explicitly.
      the "HASH" option instead, just put "include => \&Text::Tem-
  −
      plate::_load_text" into the hash instead of importing it explicitly.
     −
      Suppose you don’t want to insert a plain text file, but rather you want
+
Suppose you don’t want to insert a plain text file, but rather you want to include one template within another?  Just use "fill_in_file" in the template itself:
      to include one template within another?  Just use "fill_in_file" in the
  −
      template itself:
      
               {Text::Template::fill_in_file(filename)}
 
               {Text::Template::fill_in_file(filename)}
   −
      You can do the same importing trick if this is too much to type.
+
You can do the same importing trick if this is too much to type.
   −
Miscellaneous
+
==== Miscellaneous ====
      "my" variables
+
===== "my" variables =====
   −
      People are frequently surprised when this doesn’t work:
+
People are frequently surprised when this doesn’t work:
    
               my $recipient = ’The King’;
 
               my $recipient = ’The King’;
 
               my $text = fill_in_file(’formletter.tmpl’);
 
               my $text = fill_in_file(’formletter.tmpl’);
   −
      The text "The King" doesn’t get into the form letter.  Why not?
+
The text "The King" doesn’t get into the form letter.  Why not? Because $recipient is a "my" variable, and the whole point of "my" variables is that they’re private and inaccessible except in the scope in which they’re declared.  The template is not part of that scope, so the template can’t see $recipient.
      Because $recipient is a "my" variable, and the whole point of "my"
+
If that’s not the behavior you want, don’t use "my".  "my" means a private variable, and in this case you don’t want the variable to be private.  Put the variables into package variables in some other package, and use the "PACKAGE" option to "fill_in":
      variables is that they’re private and inaccessible except in the scope
  −
      in which they’re declared.  The template is not part of that scope, so
  −
      the template can’t see $recipient.
  −
      If that’s not the behavior you want, don’t use "my".  "my" means a pri-
  −
      vate variable, and in this case you don’t want the variable to be pri-
  −
      vate.  Put the variables into package variables in some other package,
  −
      and use the "PACKAGE" option to "fill_in":
      
               $Q::recipient = $recipient;
 
               $Q::recipient = $recipient;
 
               my $text = fill_in_file(’formletter.tmpl’, PACKAGE => ’Q’);
 
               my $text = fill_in_file(’formletter.tmpl’, PACKAGE => ’Q’);
   −
      or pass the names and values in a hash with the "HASH" option:
+
or pass the names and values in a hash with the "HASH" option:
    
               my $text = fill_in_file(’formletter.tmpl’, HASH => { recipient => $recipient });
 
               my $text = fill_in_file(’formletter.tmpl’, HASH => { recipient => $recipient });
   −
      Security Matters
+
===== Security Matters =====
 +
All variables are evaluated in the package you specify with the "PACKAGE" option of "fill_in".  if you use this option, and if your templates don’t do anything egregiously stupid, you won’t have to worry that evaluation of the little programs will creep out into the rest of your program and wreck something.
   −
      All variables are evaluated in the package you specify with the "PACK-
+
Nevertheless, there’s really no way (except with "Safe") to protect against a template that says
      AGE" option of "fill_in".  if you use this option, and if your tem-
  −
      plates don’t do anything egregiously stupid, you won’t have to worry
  −
      that evaluation of the little programs will creep out into the rest of
  −
      your program and wreck something.
  −
 
  −
      Nevertheless, there’s really no way (except with "Safe") to protect
  −
      against a template that says
      
               { $Important::Secret::Security::Enable = 0;
 
               { $Important::Secret::Security::Enable = 0;
Line 616: Line 573:  
               }
 
               }
   −
      or
+
or
    
               { $/ = "ho ho ho";  # Sabotage future uses of <FH>.
 
               { $/ = "ho ho ho";  # Sabotage future uses of <FH>.
Line 622: Line 579:  
               }
 
               }
   −
      or even
+
or even
    
               { system("rm -rf /") }
 
               { system("rm -rf /") }
   −
      so don’t go filling in templates unless you’re sure you know what’s in
+
so don’t go filling in templates unless you’re sure you know what’s in them.  If you’re worried, or you can’t trust the person who wrote the template, use the "SAFE" option.
      them.  If you’re worried, or you can’t trust the person who wrote the
+
A final warning: program fragments run a small risk of accidentally clobbering local variables in the "fill_in" function itself.  These variables all have names that begin with $fi_, so if you stay away from those names you’ll be safe.  (Of course, if you’re a real wizard you can tamper with them deliberately for exciting effects; this is actually how $OUT works.)  I can fix this, but it will make the package slower to do it, so I would prefer not to.  If you are worried about this, send me mail and I will show you what to do about it.
      template, use the "SAFE" option.
  −
    A final warning: program fragments run a small risk of accidentally
  −
      clobbering local variables in the "fill_in" function itself.  These
  −
      variables all have names that begin with $fi_, so if you stay away from
  −
      those names you’ll be safe.  (Of course, if you’re a real wizard you
  −
      can tamper with them deliberately for exciting effects; this is actu-
  −
      ally how $OUT works.)  I can fix this, but it will make the package
  −
      slower to do it, so I would prefer not to.  If you are worried about
  −
      this, send me mail and I will show you what to do about it.
        −
Alternative Delimiters
+
===== Alternative Delimiters =====
   −
      Lorenzo Valdettaro pointed out that if you are using "Text::Template"
+
Lorenzo Valdettaro pointed out that if you are using "Text::Template" to generate TeX output, the choice of braces as the program fragment delimiters makes you suffer suffer suffer.  Starting in version 1.20, you can change the choice of delimiters to something other than curly braces.
      to generate TeX output, the choice of braces as the program fragment
  −
      delimiters makes you suffer suffer suffer.  Starting in version 1.20,
  −
      you can change the choice of delimiters to something other than curly
  −
      braces.
     −
      In either the "new()" call or the "fill_in()" call, you can specify an
+
In either the "new()" call or the "fill_in()" call, you can specify an alternative set of delimiters with the "DELIMITERS" option.  For example, if you would like code fragments to be delimited by "[@--" and "--@]" instead of "{" and "}", use
      alternative set of delimiters with the "DELIMITERS" option.  For exam-
  −
      ple, if you would like code fragments to be delimited by "[@--" and
  −
      "--@]" instead of "{" and "}", use
      
               ... DELIMITERS => [ ’[@--’, ’--@]’ ], ...
 
               ... DELIMITERS => [ ’[@--’, ’--@]’ ], ...
   −
      Note that these delimiters are literal strings, not regexes.  (I tried
+
Note that these delimiters are literal strings, not regexes.  (I tried for regexes, but it complicates the lexical analysis too much.)  Note also that "DELIMITERS" disables the special meaning of the backslash, so if you want to include the delimiters in the literal text of your template file, you are out of luck---it is up to you to choose delimiters that do not conflict with what you are doing.  The delimiter strings may still appear inside of program fragments as long as they
      for regexes, but it complicates the lexical analysis too much.)  Note
+
       nest properly.  This means that if for some reason you absolutely must have a program fragment that mentions one of the delimiters, like this:
      also that "DELIMITERS" disables the special meaning of the backslash,
  −
      so if you want to include the delimiters in the literal text of your
  −
      template file, you are out of luck---it is up to you to choose delim-
  −
      iters that do not conflict with what you are doing.  The delimiter
  −
      strings may still appear inside of program fragments as long as they
  −
       nest properly.  This means that if for some reason you absolutely must
  −
      have a program fragment that mentions one of the delimiters, like this:
      
               [@--
 
               [@--
Line 668: Line 602:  
               --@]
 
               --@]
   −
      you may be able to make it work by doing this instead:
+
you may be able to make it work by doing this instead:
    
               [@--
 
               [@--
Line 675: Line 609:  
               --@]
 
               --@]
   −
      It may be safer to choose delimiters that begin with a newline charac-
+
It may be safer to choose delimiters that begin with a newline character.
      ter.
     −
      Because the parsing of templates is simplified by the absence of back-
+
Because the parsing of templates is simplified by the absence of backslash escapes, using alternative "DELIMITERS" may speed up the parsing process by 20-25%.  This shows that my original choice of "{" and "}" was very bad.
      slash escapes, using alternative "DELIMITERS" may speed up the parsing
  −
      process by 20-25%.  This shows that my original choice of "{" and "}"
  −
      was very bad.
     −
      "PREPEND" feature and using "strict" in templates
+
===== "PREPEND" =====
 +
feature and using "strict" in templates
   −
      Suppose you would like to use "strict" in your templates to detect
+
Suppose you would like to use "strict" in your templates to detect undeclared variables and the like.  But each code fragment is a separate lexical scope, so you have to turn on "strict" at the top of each and every code fragment:
      undeclared variables and the like.  But each code fragment is a sepa-
  −
      rate lexical scope, so you have to turn on "strict" at the top of each
  −
      and every code fragment:
      
               { use strict;
 
               { use strict;
Line 695: Line 623:  
                 ...
 
                 ...
 
               }
 
               }
 
+
 
 
               ...
 
               ...
 
+
 
               { # we forgot to put ‘use strict’ here
 
               { # we forgot to put ‘use strict’ here
 
                 my $result = $boo + 12;    # $boo is misspelled and should be $foo
 
                 my $result = $boo + 12;    # $boo is misspelled and should be $foo
Line 703: Line 631:  
               }
 
               }
   −
      Because we didn’t put "use strict" at the top of the second fragment,
+
Because we didn’t put "use strict" at the top of the second fragment, it was only active in the first fragment, and we didn’t get any "strict" checking in the second fragment.  Then we mispelled $foo and the error wasn’t caught.
      it was only active in the first fragment, and we didn’t get any
  −
      "strict" checking in the second fragment.  Then we mispelled $foo and
  −
      the error wasn’t caught.
     −
      "Text::Template" version 1.22 and higher has a new feature to make this
+
"Text::Template" version 1.22 and higher has a new feature to make this easier.  You can specify that any text at all be automatically added to the beginning of each program fragment.
      easier.  You can specify that any text at all be automatically added to
  −
      the beginning of each program fragment.
     −
      When you make a call to "fill_in", you can specify a
+
When you make a call to "fill_in", you can specify a
    
               PREPEND => ’some perl statements here’
 
               PREPEND => ’some perl statements here’
   −
      option; the statements will be prepended to each program fragment for
+
option; the statements will be prepended to each program fragment for that one call only.  Suppose that the "fill_in" call included a
      that one call only.  Suppose that the "fill_in" call included a
      
               PREPEND => ’use strict;’
 
               PREPEND => ’use strict;’
   −
      option, and that the template looked like this:
+
option, and that the template looked like this:
    
               { use vars ’$foo’;
 
               { use vars ’$foo’;
Line 727: Line 649:  
                 ...
 
                 ...
 
               }
 
               }
 
+
 
               ...
 
               ...
 
+
 
               { my $result = $boo + 12;    # $boo is misspelled and should be $foo
 
               { my $result = $boo + 12;    # $boo is misspelled and should be $foo
 
                 ...
 
                 ...
 
               }
 
               }
   −
      The code in the second fragment would fail, because $boo has not been
+
The code in the second fragment would fail, because $boo has not been declared.  "use strict" was implied, even though you did not write it explicitly, because the "PREPEND" option added it for you automatically.
      declared.  "use strict" was implied, even though you did not write it
  −
      explicitly, because the "PREPEND" option added it for you automati-
  −
      cally.
     −
      There are two other ways to do this.  At the time you create the tem-
+
There are two other ways to do this.  At the time you create the template object with "new", you can also supply a "PREPEND" option, in which case the statements will be prepended each time you fill in that template.  If the "fill_in" call has its own "PREPEND" option, this overrides the one specified at the time you created the template.
      plate object with "new", you can also supply a "PREPEND" option, in
+
Finally, you can make the class method call
      which case the statements will be prepended each time you fill in that
  −
      template.  If the "fill_in" call has its own "PREPEND" option, this
  −
      overrides the one specified at the time you created the template.
  −
      Finally, you can make the class method call
      
               Text::Template->always_prepend(’perl statements’);
 
               Text::Template->always_prepend(’perl statements’);
   −
      If you do this, then call calls to "fill_in" for any template will
+
If you do this, then call calls to "fill_in" for any template will attach the perl statements to the beginning of each program fragment, except where overridden by "PREPEND" options to "new" or "fill_in".
      attach the perl statements to the beginning of each program fragment,
  −
      except where overridden by "PREPEND" options to "new" or "fill_in".
     −
      Prepending in Derived Classes
+
===== Prepending in Derived Classes =====
   −
      This section is technical, and you should skip it on the first few
+
This section is technical, and you should skip it on the first few readings.
      readings.
     −
      Normally there are three places that prepended text could come from.
+
Normally there are three places that prepended text could come from. It could come from the "PREPEND" option in the "fill_in" call, from the "PREPEND" option in the "new" call that created the template object, or from the argument of the "always_prepend" call.  "Text::Template" looks for these three things in order and takes the first one that it finds.
      It could come from the "PREPEND" option in the "fill_in" call, from the
  −
      "PREPEND" option in the "new" call that created the template object, or
  −
      from the argument of the "always_prepend" call.  "Text::Template" looks
  −
      for these three things in order and takes the first one that it finds.
     −
      In a subclass of "Text::Template", this last possibility is ambiguous.
+
In a subclass of "Text::Template", this last possibility is ambiguous. Suppose "S" is a subclass of "Text::Template".  Should
      Suppose "S" is a subclass of "Text::Template".  Should
      
               Text::Template->always_prepend(...);
 
               Text::Template->always_prepend(...);
   −
      affect objects in class "Derived"?  The answer is that you can have it
+
affect objects in class "Derived"?  The answer is that you can have it either way.
      either way.
     −
      The "always_prepend" value for "Text::Template" is normally stored in
+
The "always_prepend" value for "Text::Template" is normally stored in a hash variable named %GLOBAL_PREPEND under the key "Text::Template". When "Text::Template" looks to see what text to prepend, it first looks in the template object itself, and if not, it looks in $GLOBAL_PREPEND{class} where class is the class to which the template object belongs.  If it doesn’t find any value, it looks in $GLOBAL_PREPEND{'Text::Template'}.  This means that objects in class "Derived" will be affected by
      a hash variable named %GLOBAL_PREPEND under the key "Text::Template".
  −
      When "Text::Template" looks to see what text to prepend, it first looks
  −
      in the template object itself, and if not, it looks in
  −
      $GLOBAL_PREPEND{class} where class is the class to which the template
  −
      object belongs.  If it doesn’t find any value, it looks in
  −
      $GLOBAL_PREPEND{'Text::Template'}.  This means that objects in class
  −
      "Derived" will be affected by
      
               Text::Template->always_prepend(...);
 
               Text::Template->always_prepend(...);
   −
      unless there is also a call to
+
unless there is also a call to
    
               Derived->always_prepend(...);
 
               Derived->always_prepend(...);
   −
      So when you’re designing your derived class, you can arrange to have
+
So when you’re designing your derived class, you can arrange to have your objects ignore "Text::Template::always_prepend" calls by simply putting "Derived->always_prepend('')" at the top of your module.
      your objects ignore "Text::Template::always_prepend" calls by simply
  −
      putting "Derived->always_prepend('')" at the top of your module.
  −
 
  −
      Of course, there is also a final escape hatch: Templates support a
  −
      "prepend_text" that is used to look up the appropriate text to be
  −
      prepended at "fill_in" time.  Your derived class can override this
  −
      method to get an arbitrary effect.
     −
      JavaScript
+
Of course, there is also a final escape hatch: Templates support a "prepend_text" that is used to look up the appropriate text to be prepended at "fill_in" time.  Your derived class can override this method to get an arbitrary effect.
   −
      Jennifer D. St Clair asks:
+
===== JavaScript =====
 +
Jennifer D. St Clair asks:
    
               > Most of my pages contain JavaScript and Stylesheets.
 
               > Most of my pages contain JavaScript and Stylesheets.
 
               > How do I change the template identifier?
 
               > How do I change the template identifier?
   −
      Jennifer is worried about the braces in the JavaScript being taken as
+
Jennifer is worried about the braces in the JavaScript being taken as the delimiters of the Perl program fragments.  Of course, disaster will ensue when perl tries to evaluate these as if they were Perl programs. The best choice is to find some unambiguous delimiter strings that you can use in your template instead of curly braces, and then use the "DELIMITERS" option.  However, if you can’t do this for some reason, there are  two easy workarounds:
      the delimiters of the Perl program fragments.  Of course, disaster will
  −
      ensue when perl tries to evaluate these as if they were Perl programs.
  −
      The best choice is to find some unambiguous delimiter strings that you
  −
      can use in your template instead of curly braces, and then use the
  −
      "DELIMITERS" option.  However, if you can’t do this for some reason,
  −
      there are  two easy workarounds:
     −
      1. You can put "\" in front of "{", "}", or "\" to remove its special
+
You can put "\" in front of "{", "}", or "\" to remove its special meaning.  So, for example, instead of
      meaning.  So, for example, instead of
      
                   if (br== "n3") {
 
                   if (br== "n3") {
Line 817: Line 703:  
                   }
 
                   }
   −
      you can put
+
you can put
    
                   if (br== "n3") \{
 
                   if (br== "n3") \{
Line 823: Line 709:  
                   \}
 
                   \}
   −
      and it’ll come out of the template engine the way you want.
+
and it’ll come out of the template engine the way you want.
   −
      But here is another method that is probably better.  To see how it
+
But here is another method that is probably better.  To see how it works, first consider what happens if you put this into a template:
      works, first consider what happens if you put this into a template:
      
                   { ’foo’ }
 
                   { ’foo’ }
   −
      Since it’s in braces, it gets evaluated, and obviously, this is going
+
Since it’s in braces, it gets evaluated, and obviously, this is going to turn into
      to turn into
      
                   foo
 
                   foo
   −
      So now here’s the trick: In Perl, "q{...}" is the same as '...'.  So if
+
So now here’s the trick: In Perl, "q{...}" is the same as '...'.  So if we wrote
      we wrote
      
                   {q{foo}}
 
                   {q{foo}}
   −
      it would turn into
+
it would turn into
    
                   foo
 
                   foo
   −
      So for your JavaScript, just write
+
So for your JavaScript, just write
    
                   {q{if (br== "n3") {
 
                   {q{if (br== "n3") {
Line 851: Line 734:  
                   }
 
                   }
   −
      and it’ll come out as
+
and it’ll come out as
    
                     if (br== "n3") {
 
                     if (br== "n3") {
Line 857: Line 740:  
                     }
 
                     }
   −
      which is what you want.
+
which is what you want.
   −
      Shut Up!
+
===== Shut Up! =====
   −
      People sometimes try to put an initialization section at the top of
+
People sometimes try to put an initialization section at the top of their templates, like this:
      their templates, like this:
      
               { ...
 
               { ...
Line 868: Line 750:  
               }
 
               }
   −
      Then they complain because there is a 17 at the top of the output that
+
Then they complain because there is a 17 at the top of the output that they didn’t want to have there.
      they didn’t want to have there.
     −
      Remember that a program fragment is replaced with its own return value,
+
Remember that a program fragment is replaced with its own return value, and that in Perl the return value of a code block is the value of the last expression that was evaluated, which in this case is 17.  If it didn’t do that, you wouldn’t be able to write "{$recipient}" and have the recipient filled in.
      and that in Perl the return value of a code block is the value of the
  −
      last expression that was evaluated, which in this case is 17.  If it
  −
      didn’t do that, you wouldn’t be able to write "{$recipient}" and have
  −
      the recipient filled in.
     −
      To prevent the 17 from appearing in the output is very simple:
+
To prevent the 17 from appearing in the output is very simple:
    
               { ...
 
               { ...
Line 884: Line 761:  
               }
 
               }
   −
      Now the last expression evaluated yields the empty string, which is
+
Now the last expression evaluated yields the empty string, which is invisible.  If you don’t like the way this looks, use
      invisible.  If you don’t like the way this looks, use
      
               { ...
 
               { ...
Line 892: Line 768:  
               }
 
               }
   −
      instead.  Presumably, $SILENTLY has no value, so nothing will be inter-
+
instead.  Presumably, $SILENTLY has no value, so nothing will be interpolated.  This is what is known as a ‘trick’.
      polated.  This is what is known as a ‘trick’.
     −
      Compatibility
+
===== Compatibility =====
   −
      Every effort has been made to make this module compatible with older
+
Every effort has been made to make this module compatible with older versions.  The only known exceptions follow:
      versions.  The only known exceptions follow:
     −
      The output format of the default "BROKEN" subroutine has changed twice,
+
The output format of the default "BROKEN" subroutine has changed twice, most recently between versions 1.31 and 1.40.
      most recently between versions 1.31 and 1.40.
     −
      Starting in version 1.10, the $OUT variable is arrogated for a special
+
Starting in version 1.10, the $OUT variable is arrogated for a special meaning.  If you had templates before version 1.10 that happened to use a variable named $OUT, you will have to change them to use some other variable or all sorts of strangeness will result.
      meaning.  If you had templates before version 1.10 that happened to use
  −
      a variable named $OUT, you will have to change them to use some other
  −
      variable or all sorts of strangeness will result.
     −
      Between versions 0.1b and 1.00 the behavior of the \ metacharacter
+
Between versions 0.1b and 1.00 the behavior of the \ metacharacter changed.  In 0.1b, \\ was special everywhere, and the template processor always replaced it with a single backslash before passing the code to Perl for evaluation.  The rule now is more complicated but probably more convenient.  See the section on backslash processing, below, for a full discussion.
      changed.  In 0.1b, \\ was special everywhere, and the template proces-
  −
      sor always replaced it with a single backslash before passing the code
  −
      to Perl for evaluation.  The rule now is more complicated but probably
  −
      more convenient.  See the section on backslash processing, below, for a
  −
      full discussion.
     −
      Backslash Processing
+
===== Backslash Processing =====
   −
      In "Text::Template" beta versions, the backslash was special whenever
+
In "Text::Template" beta versions, the backslash was special whenever it appeared before a brace or another backslash.  That meant that while "{"\n"}" did indeed generate a newline, "{"\\"}" did not generate a backslash, because the code passed to Perl for evaluation was "\" which is a syntax error.  If you wanted a backslash, you would have had to write "{"\\\\"}".
      it appeared before a brace or another backslash.  That meant that while
  −
      "{"\n"}" did indeed generate a newline, "{"\\"}" did not generate a
  −
      backslash, because the code passed to Perl for evaluation was "\" which
  −
      is a syntax error.  If you wanted a backslash, you would have had to
  −
      write "{"\\\\"}".
     −
      In "Text::Template" versions 1.00 through 1.10, there was a bug: Back-
+
In "Text::Template" versions 1.00 through 1.10, there was a bug: Backslash was special everywhere.  In these versions, "{"\n"}" generated the letter "n".
      slash was special everywhere.  In these versions, "{"\n"}" generated
  −
      the letter "n".
     −
      The bug has been corrected in version 1.11, but I did not go back to
+
The bug has been corrected in version 1.11, but I did not go back to exactly the old rule, because I did not like the idea of having to write "{"\\\\"}" to get one backslash.  The rule is now more complicated to remember, but probably easier to use.  The rule is now: Backslashes are always passed to Perl unchanged unless they occur as part of a sequence like "\\\\\\{" or "\\\\\\}".  In these contexts, they are special; "\\" is replaced with "\", and "\{" and "\}" signal a literal brace.
      exactly the old rule, because I did not like the idea of having to
  −
      write "{"\\\\"}" to get one backslash.  The rule is now more compli-
  −
      cated to remember, but probably easier to use.  The rule is now: Back-
  −
      slashes are always passed to Perl unchanged unless they occur as part
  −
      of a sequence like "\\\\\\{" or "\\\\\\}".  In these contexts, they are
  −
      special; "\\" is replaced with "\", and "\{" and "\}" signal a literal
  −
      brace.
     −
      Examples:
+
Examples:
    
               \{ foo \}
 
               \{ foo \}
   −
      is not evaluated, because the "\" before the braces signals that they
+
is not evaluated, because the "\" before the braces signals that they should be taken literally.  The result in the output looks like this:
      should be taken literally.  The result in the output looks like this:
      
               { foo }
 
               { foo }
   −
      This is a syntax error:
+
This is a syntax error:
    
               { "foo}" }
 
               { "foo}" }
   −
      because "Text::Template" thinks that the code ends at the first "}",
+
because "Text::Template" thinks that the code ends at the first "}", and then gets upset when it sees the second one.  To make this work correctly, use
      and then gets upset when it sees the second one.  To make this work
  −
      correctly, use
      
               { "foo\}" }
 
               { "foo\}" }
   −
      This passes "foo}" to Perl for evaluation.  Note there’s no "\" in the
+
This passes "foo}" to Perl for evaluation.  Note there’s no "\" in the evaluated code.  If you really want a "\" in the evaluated code, use
      evaluated code.  If you really want a "\" in the evaluated code, use
      
               { "foo\\\}" }
 
               { "foo\\\}" }
   −
      This passes "foo\}" to Perl for evaluation.
+
This passes "foo\}" to Perl for evaluation.
   −
      Starting with "Text::Template" version 1.20, backslash processing is
+
Starting with "Text::Template" version 1.20, backslash processing is disabled if you use the "DELIMITERS" option to specify alternative delimiter strings.
      disabled if you use the "DELIMITERS" option to specify alternative
  −
      delimiter strings.
     −
      A short note about $Text::Template::ERROR
+
===== A short note about $Text::Template::ERROR =====
   −
      In the past some people have fretted about ‘violating the package
+
In the past some people have fretted about ‘violating the package boundary’ by examining a variable inside the "Text::Template" package. Don’t feel this way.  $Text::Template::ERROR is part of the published, official interface to this package.  It is perfectly OK to inspect this variable.  The interface is not going to change.
      boundary’ by examining a variable inside the "Text::Template" package.
  −
      Don’t feel this way.  $Text::Template::ERROR is part of the published,
  −
      official interface to this package.  It is perfectly OK to inspect this
  −
      variable.  The interface is not going to change.
     −
      If it really, really bothers you, you can import a function called
+
If it really, really bothers you, you can import a function called "TTerror" that returns the current value of the $ERROR variable.  So you can say:
      "TTerror" that returns the current value of the $ERROR variable.  So
  −
      you can say:
      
               use Text::Template ’TTerror’;
 
               use Text::Template ’TTerror’;
 
+
 
               my $template = new Text::Template (SOURCE => $filename);
 
               my $template = new Text::Template (SOURCE => $filename);
 
               unless ($template) {
 
               unless ($template) {
Line 987: Line 826:  
               }
 
               }
   −
      I don’t see what benefit this has over just doing this:
+
I don’t see what benefit this has over just doing this:
    
               use Text::Template;
 
               use Text::Template;
 
+
 
 
               my $template = new Text::Template (SOURCE => $filename)
 
               my $template = new Text::Template (SOURCE => $filename)
 
                 or die "Couldn’t make template: $Text::Template::ERROR; aborting";
 
                 or die "Couldn’t make template: $Text::Template::ERROR; aborting";
   −
      But if it makes you happy to do it that way, go ahead.
+
But if it makes you happy to do it that way, go ahead.
   −
      Sticky Widgets in Template Files
+
===== Sticky Widgets in Template Files =====
   −
      The "CGI" module provides functions for ‘sticky widgets’, which are
+
The "CGI" module provides functions for ‘sticky widgets’, which are form input controls that retain their values from one page to the next. Sometimes people want to know how to include these widgets into their template output.
      form input controls that retain their values from one page to the next.
  −
      Sometimes people want to know how to include these widgets into their
  −
      template output.
     −
      It’s totally straightforward.  Just call the "CGI" functions from
+
It’s totally straightforward.  Just call the "CGI" functions from inside the template:
      inside the template:
      
               { $q->checkbox_group(NAME => ’toppings’,
 
               { $q->checkbox_group(NAME => ’toppings’,
Line 1,013: Line 848:  
               }
 
               }
   −
      Automatic preprocessing of program fragments
+
===== Automatic preprocessing of program fragments =====
 +
 
 +
It may be useful to preprocess the program fragments before they are evaluated.  See "Text::Template::Preprocess" for more details.
 +
 
 +
===== Author =====
 +
 
 +
Mark-Jason Dominus, Plover Systems
   −
      It may be useful to preprocess the program fragments before they are
+
Please send questions and other remarks about this software to "mjd-perl-template+@plover.com"
      evaluated. See "Text::Template::Preprocess" for more details.
     −
      Author
+
You can join a very low-volume (<10 messages per year) mailing list for announcements about this package.  Send an empty note to "mjd-perl-tem-plate-request@plover.com" to join.
   −
      Mark-Jason Dominus, Plover Systems
+
For updates, visit "http://www.plover.com/~mjd/perl/Template/".
   −
      Please send questions and other remarks about this software to
+
===== Support? =====
      "mjd-perl-template+@plover.com"
     −
      You can join a very low-volume (<10 messages per year) mailing list for
+
This software is version 1.45.  It may have bugs.  Suggestions and bug reports are always welcome.  Send them to "mjd-perl-tem-plate+@plover.com". (That is my address, not the address of the mailing list.  The mailing list address is a secret.)
      announcements about this package.  Send an empty note to "mjd-perl-tem-
  −
      plate-request@plover.com" to join.
     −
      For updates, visit "http://www.plover.com/~mjd/perl/Template/".
+
== LICENSE ==
 +
Text::Template version 1.45
 +
Copyright (C) 2008 Mark Jason Dominus
   −
      Support?
+
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.  You may also can redistribute it and/or modify it under the terms of the Perl Artistic License.
   −
      This software is version 1.45.  It may have bugs.  Suggestions and bug
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSESee the GNU General Public License for more details.
      reports are always welcome.  Send them to "mjd-perl-tem-
  −
      plate+@plover.com".  (That is my address, not the address of the mail-
  −
      ing listThe mailing list address is a secret.)
     −
=== LICENSE ===
+
You should have received copies of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
          Text::Template version 1.45
  −
          Copyright (C) 2008 Mark Jason Dominus
     −
          This program is free software; you can redistribute it and/or
+
== THANKS ==
          modify it under the terms of the GNU General Public License as
+
Many thanks to the following people for offering support, encouragement, advice, bug reports, and all the other good stuff.
          published by the Free Software Foundation; either version 2 of the
  −
          License, or (at your option) any later version.  You may also can
  −
          redistribute it and/or modify it under the terms of the Perl
  −
          Artistic License.
     −
          This program is distributed in the hope that it will be useful,
+
David H. Adler / Joel Appelbaum / Klaus Arnhold / Antonio Araga~o / Kevin Atteson / Chris.Brezil / Mike Brodhead / Tom Brown / Dr. Frank Bucolo / Tim Bunce / Juan E. Camacho / Itamar Almeida de Carvalho / Joseph Cheek / Gene Damon / San Deng / Bob Dougherty / Marek Grac / Dan Franklin / gary at dls.net / Todd A. Green / Donald L. Greer Jr. / Michelangelo Grigni / Zac Hansen / Tom Henry / Jarko Hietaniemi / Matt X. Hunter / Robert M. Ioffe / Daniel LaLiberte / Reuven M. Lerner / Trip Lilley / Yannis Livassof / Val Luck / Kevin Madsen / David Marshall / James Mastros / Joel Meulenberg / Jason Moore / Sergey Myasnikov / Chris Nandor / Bek Oberin / Steve Palincsar / Ron Pero / Hans Persson / Sean Roehnelt / Jonathan Roy / Shabbir J. Safdar / Jennifer D. St Clair / Uwe Schneider / Randal L. Schwartz / Michael G Schwern / Yonat Sharon / Brian C. Shensky / Niklas Skoglund / Tom Snee / Fred Steinberg / Hans Stoop / Michael J. Suzio / Dennis Taylor / James H.Thompson / Shad Todd / Lieven Tomme / Lorenzo Valdettaro / Larry Virden / Andy Wardley / Archie Warnock / Chris Wesley / Matt Womer / Andrew G Wood / Daini Xie / Michaely Yeung
          but WITHOUT ANY WARRANTY; without even the implied warranty of
  −
          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  −
          GNU General Public License for more details.
     −
          You should have received copies of the GNU General Public License
+
==== Special thanks to: ====
          along with this program; if not, write to the Free Software
  −
          Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     −
=== THANKS ===
+
===== Jonathan Roy =====
      Many thanks to the following people for offering support, encourage-
+
for telling me how to do the "Safe" support (I spent two years worrying about it, and then Jonathan pointed out that it was trivial.)
      ment, advice, bug reports, and all the other good stuff.
     −
      David H. Adler / Joel Appelbaum / Klaus Arnhold / Antonio Araga~o /
+
===== Ranjit Bhatnagar =====
      Kevin Atteson / Chris.Brezil / Mike Brodhead / Tom Brown / Dr. Frank
+
for demanding less verbose fragments like they have in ASP, for helping me figure out the Right Thing, and, especially, for talking me out of adding any new syntax. These discussions resulted in the $OUT feature.
      Bucolo / Tim Bunce / Juan E. Camacho / Itamar Almeida de Carvalho /
  −
      Joseph Cheek / Gene Damon / San Deng / Bob Dougherty / Marek Grac / Dan
  −
      Franklin / gary at dls.net / Todd A. Green / Donald L. Greer Jr. /
  −
      Michelangelo Grigni / Zac Hansen / Tom Henry / Jarko Hietaniemi / Matt
  −
      X. Hunter / Robert M. Ioffe / Daniel LaLiberte / Reuven M. Lerner /
  −
      Trip Lilley / Yannis Livassof / Val Luck / Kevin Madsen / David Mar-
  −
      shall / James Mastros / Joel Meulenberg / Jason Moore / Sergey Myas-
  −
      nikov / Chris Nandor / Bek Oberin / Steve Palincsar / Ron Pero / Hans
  −
      Persson / Sean Roehnelt / Jonathan Roy / Shabbir J. Safdar / Jennifer
  −
      D. St Clair / Uwe Schneider / Randal L. Schwartz / Michael G Schwern /
  −
      Yonat Sharon / Brian C. Shensky / Niklas Skoglund / Tom Snee / Fred
  −
      Steinberg / Hans Stoop / Michael J. Suzio / Dennis Taylor / James H.
  −
      Thompson / Shad Todd / Lieven Tomme / Lorenzo Valdettaro / Larry Virden
  −
      / Andy Wardley / Archie Warnock / Chris Wesley / Matt Womer / Andrew G
  −
      Wood / Daini Xie / Michaely Yeung
     −
      Special thanks to:
+
==== Bugs and Caveats ====
   −
      Jonathan Roy
+
"my" variables in "fill_in" are still susceptible to being clobbered by template evaluation.  They all begin with "fi_", so avoid those names in your templates.
        for telling me how to do the "Safe" support (I spent two years worry-
  −
        ing about it, and then Jonathan pointed out that it was trivial.)
     −
      Ranjit Bhatnagar
+
The line number information will be wrong if the template’s lines are not terminated by "\n".  You should let me know if this is a problem. If you do, I will fix it.
        for demanding less verbose fragments like they have in ASP, for help-
  −
        ing me figure out the Right Thing, and, especially, for talking me
  −
        out of adding any new syntax. These discussions resulted in the $OUT
  −
        feature.
     −
      Bugs and Caveats
+
The $OUT variable has a special meaning in templates, so you cannot use it as if it were a regular variable.
   −
      "my" variables in "fill_in" are still susceptible to being clobbered by
+
There are not quite enough tests in the test suite.
      template evaluation.  They all begin with "fi_", so avoid those names
  −
      in your templates.
     −
      The line number information will be wrong if the template’s lines are
+
=== SEE ALSO ===
      not terminated by "\n".  You should let me know if this is a problem.
+
[[SME_Server:Documentation:Developers_Manual#Configuration_file_templates| Templated Configuration System]]<br />
      If you do, I will fix it.
     −
      The $OUT variable has a special meaning in templates, so you cannot use
+
[http://wiki.contribs.org/Esmith::templates Esmith::templates]
      it as if it were a regular variable.
     −
      There are not quite enough tests in the test suite.
+
[[Category:SME Server Development Framework]]
 +
[[Category:Development Tools]]
 +
[[Category:SME9-Development]]

Navigation menu