File: README

package info (click to toggle)
libtext-template-perl 1.45-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 228 kB
  • ctags: 25
  • sloc: perl: 1,365; makefile: 15
file content (326 lines) | stat: -rw-r--r-- 11,222 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326

Text::Template v1.44

This is a library for generating form letters, building HTML pages, or
filling in templates generally.  A `template' is a piece of text that
has little Perl programs embedded in it here and there.  When you
`fill in' a template, you evaluate the little programs and replace
them with their values.  

Here's an example of a template:

	Dear {$title} {$lastname},

	It has come to our attention that you are delinquent in your
	{$monthname[$last_paid_month]} payment.  Please remit
	${sprintf("%.2f", $amount)} immediately, or your patellae may
	be needlessly endangered.

			Love,

			Mark "{nickname(rand 20)}" Dominus


The result of filling in this template is a string, which might look
something like this:

	Dear Mr. Gates,

	It has come to our attention that you are delinquent in your
	February payment.  Please remit
	$392.12 immediately, or your patellae may
	be needlessly endangered.


			Love,

			Mark "Vizopteryx" Dominus

You can store a template in a file outside your program.  People can
modify the template without modifying the program.  You can separate
the formatting details from the main code, and put the formatting
parts of the program into the template.  That prevents code bloat and
encourages functional separation.

You can fill in the template in a `Safe' compartment.  This means that
if you don't trust the person who wrote the code in the template, you
won't have to worry that they are tampering with your program when you
execute it.  

----------------------------------------------------------------

Text::Template was originally released some time in late 1995 or early
1996.  After three years of study and investigation, I rewrote it from
scratch in January 1999.  The new version, 1.0, was much faster,
delivered better functionality and was almost 100% backward-compatible
with the previous beta versions.

I have added a number of useful features and conveniences since the
1.0 release, while still retaining backward compatibility.  With one
merely cosmetic change, the current version of Text::Template passes
the test suite that the old beta versions passed.

Questions or comments should be addressed to
mjd-perl-template+@plover.com.  This address goes directly to me, and
not to anyone else; it is not a mailing list address.

To receive occasional announcements of new versions of T::T, send an
empty note to mjd-perl-template-request@plover.com.  This mailing list
is not for discussion; it is for announcements only.  Therefore, there
is no address for sending messages to the list.

You can get the most recent version of Text::Template, news, comments,
and other collateral information from
<URL:http://www.plover.com/~mjd/perl/Template/>.

----------------------------------------------------------------
What's new in v1.44 since v1.43: 

This is a maintentance release.  There are no feature changes.

        _scrubpkg, which was responsible for eptying out temporary
        packages after the module had done with them, wasn't always
        working; the result was memory-leaks in long-running
        applications.  This should be fixed now, and there is a test
        in the test suite for it.

        Minor changes to the test suite to prevent spurious errors.

        Minor documentation changes.

----------------------------------------------------------------
What's new in v1.43 since v1.42:

        The ->new method now fails immediately and sets
        $Text::Template::ERROR if the file that is named by a filename
        argument does not exist or cannot be opened for some other
        reason.  Formerly, the constructor would succeed and the
        ->fill_in call would fail.

----------------------------------------------------------------

What's new in v1.42 since v1.41:

This is a maintentance release.  There are no feature changes.

        Fixed a bug relating to use of UNTAINT under perl 5.005_03 and
        possibly other versions.

        Taint-related tests are now more comprehensive.
----------------------------------------------------------------

What's new in v1.41 since v1.40:

This is a maintentance release.  There are no feature changes.

        Tests now work correctly on Windows systems and possibly on
        other non-unix systems.

----------------------------------------------------------------

What's new in v1.40 since v1.31:

        New UNTAINT option tells the module that it is safe to 'eval'
        code even though it has come from a file or filehandle.

        Code added to prevent memory leaks when filling many
        templates.  Thanks to Itamar Almeida de Carvalho.

        Bug fix:  $OUT was not correctly initialized when used in
        conjunction with SAFE.

        You may now use a glob ref when passing a filehandle to the
        ->new funcion.  Formerly, a glob was reuqired.

        New subclass:  Text::Template::Preprocess.  Just like
        Text::Template, but you may supply a PREPROCESS option in the
        constructor or the fill_in call; this is a function which
        receives each code fragment prior to evaluation, and which may
        modify and return the fragment; the modified fragment is what
        is evaluated.

        Error messages passed to BROKEN subroutines will now report
        the correct line number of the template at which the error
        occurred:

                Illegal division by zero at template line 37.

        If the template comes from a file, the filename will be
        reported as well:

                Illegal division by zero at catalog.tmpl line 37.


        INCOMPATIBLE CHANGE:

        The format of the default error message has changed.  It used
        to look like:

                Program fragment at line 30 delivered error ``Illegal division by zero''

        It now looks like:

                Program fragment delivered error ``Illegal division by zero at catalog.tmpl line 37''

        Note that the default message used to report the line number
        at which the program fragment began; it now reports the line
        number at which the error actually occurred.

----------------------------------------------------------------
What's new in v1.31 since v1.23:

	Just bug fixes---fill_in_string was failing.  Thanks to 
        Donald L. Greer Jr. for the test case.

----------------------------------------------------------------
What's new in v1.23 since v1.22:

	Small bug fix:  DELIMITER and other arguments were being
	ignored in calls to fill_in_file and fill_this_in.  (Thanks to
	Jonathan Roy for reporting this.)

----------------------------------------------------------------
What's new in v1.22 since v1.20:

	You can now specify that certain Perl statements be prepended
	to the beginning of every program fragment in a template,
	either per template, or for all templates, or for the duration
	of only one call to fill_in.  This is useful, for example, if
	you want to enable `strict' checks in your templates but you
	don't want to manually add `use strict' to the front of every
	program fragment everywhere.

----------------------------------------------------------------
What's new in v1.20 since v1.12:

	You can now specify that the program fragment delimiters are
	strings other than { and }.  This has three interesting
	effects: First, it changes the delimiter strings.  Second, it
	disables the special meaning of \, so you have to be really,
	really sure that the delimiters will not appear in your
	templates.  And third, because of the simplifications
	introduced by the elimination of \ processing, template
	parsing is 20-25% faster.

	See the manual section on `Alternative Delimiters'.

	Fixed bug having to do with undefined values in HASH options.
	In particular, Text::Template no longer generates a warning if
	you try to give a variable an undefined value.

----------------------------------------------------------------

What's new in v1.12 since v1.11:

	I forgot to say that Text::Template ISA Exporter, so the
	exported functions never got exported.  Duhhh!

	Template TYPEs are now case-insensitive.  The `new' method now
	diagnoses attempts to use an invalid TYPE.

	More tests for these things.

----------------------------------------------------------------

What's new in v1.11 since v1.10:

	Fixed a bug in the way backslashes were processed.  The 1.10
	behavior was incompatible with the beta versions and was also
	inconvenient.  (`\n' in templates was replaced with `n' before
	it was given to Perl for evaluation.)  The new behavior is
	also incompatible with the beta versions, but it is only a
	little bit incompatible, and it is probbaly better.

	Documentation for the new behavior, and tests for the bug.

----------------------------------------------------------------

What's new in v1.10 since v1.03:

	New OUTPUT option delivers template results directly to a
	filehandle instead of making them into a string.  Saves space
	and time. 

	PACKAGE and HASH now work intelligently with SAFE.

	Fragments may now output data directly to the template, rather
	than having to arrange to return it as a return value at the
	end.  This means that where you used to have to write this:

			{ my $blist = '';
		          foreach $i (@items) {
		            $blist .= qq{  * $i\n};
		          }    
		          $blist;
		        } 

	You can now write this instead, because $OUT is special.

			{ foreach $i (@items) {
		            $OUT.= "  * $i\n";
		          }    
		        } 

	(`A spoonful of sugar makes the medicine go down.')

	Fixed some small bugs.  Worked around a bug in Perl that does
	the wrong thing with $x = <Y> when $x contains a glob.

	More documentation.  Errors fixed.

	Lots more tests.  

----------------------------------------------------------------

What's new in v1.03 since v1.0:

	Code added to support HASH option to fill_in.
	(Incl. `_gensym' function.)
	
	Documentation for HASH.
	
	New test file for HASH.
	
	Note about failure of lexical variables to propagate into
 	templates.  Why does this surprise people?
	
	Bug fix: program fragments are evaluated in an environment with
 	`no strict' by default.  Otherwise, you get a lot of `Global
 	symbol "$v" requires explicit package name' failures.  Why didn't
 	the test program pick this up?  Because the only variable the test
 	program ever used was `$a', which is exempt.  Duhhhhh.
	
	Fixed the test program.
	
	Various minor documentation fixes.



----------------------------------------------------------------

Improvements of 1.0 over the old 0.1beta:

New features:

      At least twice as fast 

      Better support for filling out the same template more than once 

      Now supports evaluation of program fragments in Safe
      compartments. (Thanks, Jonathan!)  

      Better argument syntax 

      More convenience functions 

      The parser is much better and simpler. 

      Once a template is parsed, the parsed version is stored so that
      it needn't be parsed again.  

      BROKEN function behavior is rationalized. You can now pass an
      arbitrary argument to your BROKEN function, or return a value
      from it to the main program.  

      Documentation overhauled.