Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

2.03b

git-svn-id: svn://svn.tt2.org/tt/Template2/trunk@138 d5a88997-0a34-4036-9ed2-92fb5d660d91
  • Loading branch information...
commit 6c54b0a2a98038dccf0e39de93761a4e198451fb 1 parent 9acc796
@abw authored
Showing with 1,597 additions and 788 deletions.
  1. +66 −1 Changes
  2. +9 −9 README
  3. +131 −2 TODO
  4. +2 −2 bin/tpage
  5. +2 −2 bin/ttree
  6. +2 −2 docs/src/FAQ/FAQ.html
  7. +2 −2 docs/src/Library/HTML.html
  8. +2 −2 docs/src/Library/PostScript.html
  9. +2 −2 docs/src/Library/Splash.html
  10. +1 −1  docs/src/Manual/Config.html
  11. +1 −1  docs/src/Manual/Credits.html
  12. +1 −1  docs/src/Manual/Directives.html
  13. +1 −1  docs/src/Manual/Filters.html
  14. +1 −1  docs/src/Manual/Internals.html
  15. +1 −1  docs/src/Manual/Intro.html
  16. +1 −1  docs/src/Manual/Plugins.html
  17. +1 −1  docs/src/Manual/Refs.html
  18. +1 −1  docs/src/Manual/Syntax.html
  19. +1 −1  docs/src/Manual/Variables.html
  20. +1 −1  docs/src/Manual/Views.html
  21. +1 −1  docs/src/Modules/Template.html
  22. +2 −2 docs/src/Modules/Template/Base.html
  23. +2 −2 docs/src/Modules/Template/Config.html
  24. +2 −2 docs/src/Modules/Template/Constants.html
  25. +2 −2 docs/src/Modules/Template/Context.html
  26. +2 −2 docs/src/Modules/Template/Document.html
  27. +2 −2 docs/src/Modules/Template/Exception.html
  28. +2 −2 docs/src/Modules/Template/Filters.html
  29. +2 −2 docs/src/Modules/Template/Iterator.html
  30. +2 −2 docs/src/Modules/Template/Parser.html
  31. +2 −2 docs/src/Modules/Template/Plugin.html
  32. +2 −2 docs/src/Modules/Template/Plugin/Autoformat.html
  33. +2 −2 docs/src/Modules/Template/Plugin/CGI.html
  34. +16 −1 docs/src/Modules/Template/Plugin/DBI.html
  35. +2 −2 docs/src/Modules/Template/Plugin/Datafile.html
  36. +2 −2 docs/src/Modules/Template/Plugin/Date.html
  37. +2 −2 docs/src/Modules/Template/Plugin/Directory.html
  38. +2 −2 docs/src/Modules/Template/Plugin/Dumper.html
  39. +2 −2 docs/src/Modules/Template/Plugin/File.html
  40. +2 −2 docs/src/Modules/Template/Plugin/Format.html
  41. +2 −2 docs/src/Modules/Template/Plugin/Iterator.html
  42. +2 −2 docs/src/Modules/Template/Plugin/Pod.html
  43. +2 −2 docs/src/Modules/Template/Plugin/Table.html
  44. +2 −2 docs/src/Modules/Template/Plugin/URL.html
  45. +2 −2 docs/src/Modules/Template/Plugin/View.html
  46. +2 −2 docs/src/Modules/Template/Plugin/Wrap.html
  47. +1 −1  docs/src/Modules/Template/Plugin/XML/DOM.html
  48. +2 −2 docs/src/Modules/Template/Plugin/XML/RSS.html
  49. +2 −2 docs/src/Modules/Template/Plugin/XML/Simple.html
  50. +2 −2 docs/src/Modules/Template/Plugin/XML/XPath.html
  51. +2 −2 docs/src/Modules/Template/Plugins.html
  52. +2 −2 docs/src/Modules/Template/Provider.html
  53. +2 −2 docs/src/Modules/Template/Service.html
  54. +2 −2 docs/src/Modules/Template/Stash.html
  55. +2 −2 docs/src/Modules/Template/Test.html
  56. +66 −1 docs/src/Release/Changes.html
  57. +9 −9 docs/src/Release/README.html
  58. +131 −2 docs/src/Release/TODO.html
  59. +2 −2 docs/src/Tools/tpage.html
  60. +2 −2 docs/src/Tools/ttree.html
  61. +1 −1  docs/src/Tutorial/Datafile.html
  62. +1 −1  docs/src/Tutorial/Web.html
  63. +28 −2 docsrc/src/Release/Changes.tt2
  64. +125 −1 docsrc/src/Release/TODO.tt2
  65. +2 −2 lib/Template.pm
  66. +2 −2 lib/Template/Base.pm
  67. +2 −2 lib/Template/Config.pm
  68. +2 −2 lib/Template/Constants.pm
  69. +2 −2 lib/Template/Context.pm
  70. +4 −3 lib/Template/Directive.pm
  71. +2 −2 lib/Template/Document.pm
  72. +2 −2 lib/Template/Exception.pm
  73. +3 −3 lib/Template/FAQ.pod
  74. +37 −4 lib/Template/Filters.pm
  75. +515 −498 lib/Template/Grammar.pm
  76. +2 −2 lib/Template/Iterator.pm
  77. +3 −3 lib/Template/Library/HTML.pod
  78. +3 −3 lib/Template/Library/PostScript.pod
  79. +3 −3 lib/Template/Library/Splash.pod
  80. +1 −1  lib/Template/Manual.pod
  81. +1 −1  lib/Template/Manual/Config.pod
  82. +1 −1  lib/Template/Manual/Credits.pod
  83. +1 −1  lib/Template/Manual/Directives.pod
  84. +1 −1  lib/Template/Manual/Filters.pod
  85. +1 −1  lib/Template/Manual/Internals.pod
  86. +1 −1  lib/Template/Manual/Intro.pod
  87. +1 −1  lib/Template/Manual/Plugins.pod
  88. +1 −1  lib/Template/Manual/Refs.pod
  89. +1 −1  lib/Template/Manual/Syntax.pod
  90. +1 −1  lib/Template/Manual/Variables.pod
  91. +1 −1  lib/Template/Manual/Views.pod
  92. +1 −1  lib/Template/Modules.pod
  93. +2 −2 lib/Template/Parser.pm
  94. +2 −2 lib/Template/Plugin.pm
  95. +2 −2 lib/Template/Plugin/Autoformat.pm
  96. +2 −2 lib/Template/Plugin/CGI.pm
  97. +18 −3 lib/Template/Plugin/DBI.pm
  98. +2 −2 lib/Template/Plugin/Datafile.pm
  99. +2 −2 lib/Template/Plugin/Date.pm
  100. +2 −2 lib/Template/Plugin/Directory.pm
  101. +2 −2 lib/Template/Plugin/Dumper.pm
  102. +2 −2 lib/Template/Plugin/File.pm
  103. +2 −2 lib/Template/Plugin/Format.pm
  104. +2 −2 lib/Template/Plugin/GD/Constants.pm
  105. +3 −3 lib/Template/Plugin/GD/Graph/area.pm
  106. +3 −3 lib/Template/Plugin/GD/Graph/bars.pm
  107. +3 −3 lib/Template/Plugin/GD/Graph/bars3d.pm
  108. +3 −3 lib/Template/Plugin/GD/Graph/lines.pm
  109. +3 −3 lib/Template/Plugin/GD/Graph/lines3d.pm
  110. +3 −3 lib/Template/Plugin/GD/Graph/linespoints.pm
  111. +3 −3 lib/Template/Plugin/GD/Graph/mixed.pm
  112. +3 −3 lib/Template/Plugin/GD/Graph/pie.pm
  113. +3 −3 lib/Template/Plugin/GD/Graph/pie3d.pm
  114. +3 −3 lib/Template/Plugin/GD/Graph/points.pm
  115. +2 −2 lib/Template/Plugin/GD/Image.pm
  116. +2 −2 lib/Template/Plugin/GD/Polygon.pm
  117. +2 −2 lib/Template/Plugin/GD/Text.pm
  118. +2 −2 lib/Template/Plugin/GD/Text/Align.pm
  119. +2 −2 lib/Template/Plugin/GD/Text/Wrap.pm
  120. +2 −2 lib/Template/Plugin/HTML.pm
  121. +2 −2 lib/Template/Plugin/Iterator.pm
  122. +2 −2 lib/Template/Plugin/Pod.pm
  123. +2 −2 lib/Template/Plugin/Table.pm
  124. +2 −2 lib/Template/Plugin/URL.pm
  125. +2 −2 lib/Template/Plugin/View.pm
  126. +2 −2 lib/Template/Plugin/Wrap.pm
  127. +1 −1  lib/Template/Plugin/XML/DOM.pm
  128. +2 −2 lib/Template/Plugin/XML/RSS.pm
  129. +2 −2 lib/Template/Plugin/XML/Simple.pm
  130. +3 −2 lib/Template/Plugin/XML/XPath.pm
  131. +2 −2 lib/Template/Plugins.pm
  132. +2 −2 lib/Template/Provider.pm
  133. +2 −2 lib/Template/Service.pm
  134. +3 −3 lib/Template/Stash.pm
  135. +2 −2 lib/Template/Stash/Context.pm
  136. +2 −2 lib/Template/Test.pm
  137. +2 −2 lib/Template/Tools/tpage.pod
  138. +2 −2 lib/Template/Tools/ttree.pod
  139. +1 −1  lib/Template/Tutorial.pod
  140. +1 −1  lib/Template/Tutorial/Datafile.pod
  141. +1 −1  lib/Template/Tutorial/Web.pod
  142. +9 −4 parser/Parser.yp
  143. +2 −2 t/dbi.t
  144. +74 −4 t/foreach.t
  145. +12 −0 t/html.t
  146. +22 −1 t/object.t
  147. +81 −0 t/while.t
  148. +2 −2 t/xpath.t
View
67 Changes
@@ -3,7 +3,7 @@
# Changes
#
# DESCRIPTION
-# Revision history for the Template Toolkit version 2.03a, detailing
+# Revision history for the Template Toolkit version 2.03b, detailing
# significant changes between versions, most recent first. Some
# way down the file you'll find a section detailing major changes from
# version 1.* to 2.* and a list of "Gotchas!" that you might have to
@@ -17,6 +17,71 @@
#========================================================================
#------------------------------------------------------------------------
+# Version 2.03b - 25th June 2001 ## DEVELOPER PRE-RELEASE FOR v2.04 ##
+#------------------------------------------------------------------------
+
+* Applied a patch from Craig Barratt to both the regular
+ Template::Stash and the alternate Template::Stash::Context which
+ allows array indexes into hashes and arrays (slices) in the same
+ manner as Perl. For example:
+
+ [% keys = [ 'foo', 'bar' ]
+ vals = hash.$keys # [ hash.foo, hash.bar ]
+
+ keys = [ 2, 3, 7 ]
+ vals = list.$keys # [ list.2, list.3, list.7 ]
+ %]
+
+* Applied another patch from Craig to Parser.pm which fixes a bug
+ relating to text strings being interpolated in a numerical context.
+ See: http://www.tt2.org/pipermail/templates/2001-April/000901.html
+
+* Applied yet another patch from Craig ("Man of the Patch" for v2.04 :-),
+ to fix a problem with NEXT not working inside switch:
+
+ FOREACH and WHILE now get a LOOP: label, and NEXT and LAST now
+ generate "next LOOP;" and "last LOOP;". However, the original
+ code allows naked "NEXT" or "LAST" (which behave like STOP). I
+ didn't want to change this behavior, so NEXT and LAST only get the
+ LOOP label inside loops (except in the top-level atomexpr FOREACH
+ and atomexpr WHILE cases, which should be ok).
+
+* Applied a patch from Mark Fowler, which fixes the problem with
+ search/replace virtual methods incorrectly returning with a search
+ pattern of '0'. e.g. [% bob = '0'; bob.replace('0', 'zero') %]
+ now returns 'zero' instead of ''.
+
+* Applied a patch from Doug Steinwand to prevent the Stash from
+ raising undef error reporting 'Can't locate object methof "bar" via
+ package "Foo"' unless $DEBUG is enabled.
+
+* Applied a patch to the DBI plugin from Rafael Kitover which calls
+ the DBI connect_cached() method instead of connect() to allow
+ connection caching in a persistant server environment (e.g. Apache
+ mod_perl).
+
+* Changed html filter to be a dynamic filter factory, allowing the
+ 'entity' option to be set to prevent entities of the form
+ '&word;' being converted to '&word;'
+
+ [% FILTER html(entity = 1) %]
+ < &amp; > # &lt; &amp; &gt;
+ [% END %]
+
+* Changed Template::Stash to propogate any object errors that
+ are references (e.g. Template::Exception objects or otherwise)
+ or string that don't look like "Can't locate object method ...".
+
+* Fixed various typos in docsrc/xml/ttdocsrc with a deft:
+ s/Plugin::GD::Graphs/Plugin::GD::Graph/g;
+
+* Applied a patch from Leon Brocard to remove a suspect test from
+ t/filter.t which Chris Nandor reported as causing problems.
+
+* Added Craig's comments on replace backreferences and TT grammar to
+ TODO list.
+
+#------------------------------------------------------------------------
# Version 2.03a - 18th June 2001 ## DEVELOPER PRE-RELEASE FOR v2.04 ##
#------------------------------------------------------------------------
View
18 README
@@ -1,9 +1,9 @@
Template Toolkit
- Version 2.03a
+ Version 2.03b
- 18 June 2001
+ 25 June 2001
Copyright (C) 1996-2001 Andy Wardley. All Rights Reserved
Copyright (C) 1998-2001 Canon Research Centre Europe Ltd.
@@ -42,8 +42,8 @@ need to install them. They're all available from CPAN if you do.
To install the Template Toolkit:
- tar zxf Template-Toolkit-2.03a.tar.gz
- cd Template-Toolkit-2.03a
+ tar zxf Template-Toolkit-2.03b.tar.gz
+ cd Template-Toolkit-2.03b
perl Makefile.PL
make
make test
@@ -293,19 +293,19 @@ The Template Toolkit is distributed as a gzipped tar archive file:
Template-Toolkit-<version>.tar.gz
-where <version> represents the current version number, e.g. 2.03a.
+where <version> represents the current version number, e.g. 2.03b.
To install the Template Toolkit, unpack the distribution archive to
create an installation directory. Something like this:
- tar zxf Template-Toolkit-2.03a.tar.gz
+ tar zxf Template-Toolkit-2.03b.tar.gz
or
- gunzip Template-Toolkit-2.03a.tar.gz
- tar xf Template-Toolkit-2.03a.tar
+ gunzip Template-Toolkit-2.03b.tar.gz
+ tar xf Template-Toolkit-2.03b.tar
You can then 'cd' into the directory created,
- cd Template-Toolkit-2.03a
+ cd Template-Toolkit-2.03b
and perform the usual Perl installation procedure:
View
133 TODO
@@ -3,7 +3,7 @@
# TODO
#
# DESCRIPTION
-# TODO list for the Template Toolkit version 2.03a, containing
+# TODO list for the Template Toolkit version 2.03b, containing
# known bugs, limitations, planned enhancements, long term visions
# and a few whacky ideas.
#
@@ -78,6 +78,45 @@
maps to the samed compiled version) but is convenient for those times
when you know that's not going to be a problem.
+* Richard Tietjen's patch for stash replace. Allows back references
+ (e.g. $1) but it would be nice to find a rock-solid way to implement
+ it without relying on unusual ^A delimiter character.
+
+* Further to the above, Craig Barratt has this solution which will be
+ going into the next verion (2.05) unless anyone has any further
+ suggestions to make before then.
+
+ It would be great if replace handled backreferences. I don't like
+ the ^A solution since the string could contain ^A, plus it is a
+ security hole. The attempt I posted only works for up to 9
+ backreferences and doesn't handle an escaped '\$' and uses nested
+ evals:
+
+ $str =~ s{$search}{
+ my $r = $replace;
+ my @d = (0, $1, $2, $3, $4, $5, $6, $7, $8, $9);
+ $r =~ s/\$(\d+)/$d[$1]/eg;
+ $r;
+ }eg;
+
+ I wish there was a perl predefined variable array containing all
+ the backreferences (is there one?). You can avoid the hard-coded
+ limit of 9 with extra evals, and a bit of work on the re could
+ handle the escaped '\$' case, so maybe that would be good enough.
+
+* Craig also notes, in fixing the problem with NEXT not working
+ inside SWITCH (see Changes v2.04):
+
+ By the way, I came across another arcane bug:
+
+ NEXT FOREACH k = [1];
+
+ is legal syntax but is an infinite loop, since $_[0]->{ INFOR } in
+ Parser.yp is not set when the NEXT is parsed, so it generates a
+ plain "next;" rather than calling $factor->next(). I don't see an
+ easy, clean fix.
+
+
#------------------------------------------------------------------------
# Documentation
#------------------------------------------------------------------------
@@ -158,7 +197,8 @@
#------------------------------------------------------------------------
* Lists don't accept arbitrary expressions as elements. In other words
- you can't do this: [% foo(bar + 1) %]
+ you can't do this: [% foo(bar + 1) %]. This has been fixed in the v3
+ parser. See http://www.tt2.org/v3/
* Stas reported a problem with spacing, something like : [% a =b+10 %] but
I can't seem to reproduce it (or remember exactly what the problem
@@ -246,6 +286,95 @@
major one) but I haven't really considered them yet so watch this
space for details.
+* Craig Barratt reports the following:
+
+ I looked at Parse.yp to see how hard it would be to push FILTER
+ evaluation down into the expr rule, so that you could put filters
+ inside expressions (eg: using repeat() just like &quot;x&quot; in
+ perl). More about that later.
+
+ In browsing through Parser.yp I noticed several issues:
+
+ - The operator precedence is very different to perl, C etc.
+ For example, these expressions evaluate differently in
+ TT2 versus perl, C etc:
+
+ + "1 || 0 && 0" evaluates to 0 in TT2 and 1 in perl or C.
+ TT2 parses it as (1||0) && 0; in perl and C && is higher
+ precedence than ||.
+
+ + "1 + !0 + 1" evaluates to 1 in TT2 and 3 in perl or C.
+ TT2 parses it as 1 + !(0 + 1); in perl and C ! is higher
+ precedence than +.
+
+ + Many other expressions parse incorrectly, but the effect
+ is benign since most rules return flat text that perl
+ correctly re-parses. Eg, 2 * 3 + 4 is incorrectly parsed
+ as (2 * (3 + 4)), but happily just the string "2 * 3 + 4"
+ is compiled by perl, which correctly evaluates it as
+ (2 * 3) + 4.
+
+ - There is no unary minus and the NUMBER token is signed. So you can
+ write "x = -2;" but not "x = -y;". Moreover, "x = 1 -1;" is a syntax
+ error (since "1 -1" returns just two tokens NUMBER, NUMBER). (As a
+ workaround you can rewrite these as "x = 0-y;" and "x = 1 - 1".)
+
+ - You cannot have expressions in lists ([..]) and function arguments.
+
+ I have modified the Parser.pm (to make NUMBER unsigned) and modified
+ Grammar.pm.skel and Parser.yp to fix most of these issues (improved
+ operator precedence, unary minus and plus), and also to allow
+ expressions in a few more places (eg: range). But the last item
+ has me stuck.
+
+ The parse rules for lists and function arguments make COMMA optional,
+ so you can equivalently write [1 2 3 4] or [1,,,,,2 3 4] or [1,2,3,4].
+ This makes it very difficult to make each term an expression, because
+ the resulting grammar has many ambiguities. For example, is [1 -1]
+ two elements [1, -1] or a single element [0]? One partial solution is
+ to move the bracketed expression rule '(' expr ')' to the term rule,
+ allowing expressions to be included via parens. But there are also
+ ambiguities, eg: does [foo (1+1)] have 2 elements or is it a function
+ call to foo?
+
+ Without allowing expressions in lists or function arguments, the unary
+ minus change I've made means that the NUMBER token is unsigned, so with
+ my changes you cannot write [-1, 2, 3]. Not a good thing.
+
+ One solution is to change the grammar so that COMMAs are required in
+ lists and arguments, but that would break several test cases and
+ probably break lots of old templates. But this might be the only
+ way to produce a grammar that is a lot more similar to perl.
+
+ Another solution is to ignore these issues altogether and use temporary
+ variables to precompute expressions that you need in lists or function
+ arguments, or use explicit lvalue assignments, eg:
+
+ foo(x + 2); becomes temp = x + 2;
+ foo(temp);
+
+ or
+
+ List = [x+1,x+2,x+4]; becomes List = [];
+ List.0 = x+1;
+ List.1 = x+2;
+ List.2 = x+4;
+
+ Both of these look ugly to me.
+
+ Back to the FILTER issues. Ultimately I'd like to be able to embed filters
+ as low precedence operators in expressions, and write:
+
+ List = [
+ "foo" | repeat(10),
+ "bar" | repeat(10)
+ ];
+
+ but I doubt there is a non-ambiguous upward compatible grammar that
+ supports this.
+
+ Comments?
+
#------------------------------------------------------------------------
# Plugins
View
4 bin/tpage
@@ -112,8 +112,8 @@ L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
=head1 COPYRIGHT
View
4 bin/ttree
@@ -627,8 +627,8 @@ L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
=head1 COPYRIGHT
View
4 docs/src/FAQ/FAQ.html
@@ -207,8 +207,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Library/HTML.html
@@ -307,8 +307,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Library/PostScript.html
@@ -39,8 +39,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Library/Splash.html
@@ -980,8 +980,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Manual/Config.html
@@ -1521,7 +1521,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Manual/Credits.html
@@ -132,7 +132,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Manual/Directives.html
@@ -1941,7 +1941,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Manual/Filters.html
@@ -417,7 +417,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Manual/Internals.html
@@ -363,7 +363,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Manual/Intro.html
@@ -253,7 +253,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Manual/Plugins.html
@@ -441,7 +441,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Manual/Refs.html
@@ -123,7 +123,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Manual/Syntax.html
@@ -269,7 +269,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Manual/Variables.html
@@ -962,7 +962,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Manual/Views.html
@@ -602,7 +602,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Modules/Template.html
@@ -811,7 +811,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Base.html
@@ -98,8 +98,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.14, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.15, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Config.html
@@ -137,8 +137,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.12, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.13, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Constants.html
@@ -89,8 +89,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.13, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.14, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Context.html
@@ -612,8 +612,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.19, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.20, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Document.html
@@ -190,8 +190,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.14, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.15, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Exception.html
@@ -79,8 +79,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.10, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.11, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Filters.html
@@ -600,8 +600,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.15, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.16, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Iterator.html
@@ -215,8 +215,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.12, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.13, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Parser.html
@@ -444,8 +444,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.17, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.18, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
<pre> </pre>
[%- END %]
View
4 docs/src/Modules/Template/Plugin.html
@@ -228,8 +228,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.13, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.14, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/Autoformat.html
@@ -140,8 +140,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.12, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.13, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/CGI.html
@@ -70,8 +70,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
17 docs/src/Modules/Template/Plugin/DBI.html
@@ -36,6 +36,8 @@
<pre> # ...or call connect() explicitly
[% tt_start_tag %] USE DBI [% tt_end_tag %]
[% tt_start_tag %] DBI.connect(dsn, user, pass) [% tt_end_tag %]</pre>
+<pre> # Or don't connect at all, and when necessary DBI will connect
+ # automatically using the environment variable DBI_DSN. See below.</pre>
<pre> [% tt_start_tag %] FOREACH item = DBI.query( 'SELECT rows FROM table' ) [% tt_end_tag %]
Here's some row data: [% tt_start_tag %] item.field [% tt_end_tag %]
[% tt_start_tag %] END [% tt_end_tag %]</pre>
@@ -90,6 +92,19 @@
</p>
<pre> [% tt_start_tag %] USE DBI(dsn, user, pass, ChopBlanks=1) [% tt_end_tag %]</pre>
<p>
+The DBI connect_cached() method is used instead of the connect()
+method. This allows for connection caching in a server environment,
+such as when the Template Toolkit is used from an Apache mod_perl
+handler. In such a case, simply enable the mod_env module and put in a
+line such as:
+</p>
+<p>
+SetEnv DBI_DSN &quot;dbi:DBDriver:DBName;host=DBHost;user=User;password=Password&quot;
+</p>
+<p>
+Then use the DBI plugin without any parameters and without calling connect.
+</p>
+<p>
Methods can then be called on the plugin object using the familiar dotted
notation:
</p>
@@ -216,7 +231,7 @@
title="VERSION"
-%]<p>
1.04, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/Datafile.html
@@ -90,8 +90,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.13, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.14, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/Date.html
@@ -132,8 +132,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/Directory.html
@@ -232,8 +232,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/Dumper.html
@@ -87,8 +87,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/File.html
@@ -263,8 +263,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/Format.html
@@ -49,8 +49,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.12, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.13, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/Iterator.html
@@ -51,8 +51,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.10, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.11, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/Pod.html
@@ -49,8 +49,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.09, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.10, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/Table.html
@@ -192,8 +192,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.12, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.13, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/URL.html
@@ -118,8 +118,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.12, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.13, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/View.html
@@ -55,8 +55,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/Wrap.html
@@ -88,8 +88,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Modules/Template/Plugin/XML/DOM.html
@@ -393,7 +393,7 @@
title="VERSION"
-%]<p>
2.6, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/XML/RSS.html
@@ -123,8 +123,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.10, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.11, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/XML/Simple.html
@@ -55,8 +55,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.09, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.10, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugin/XML/XPath.html
@@ -92,8 +92,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Plugins.html
@@ -648,8 +648,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.15, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.16, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Provider.html
@@ -367,8 +367,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.12, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.14, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Service.html
@@ -430,8 +430,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.12, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.14, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Stash.html
@@ -158,8 +158,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.20, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.21, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Modules/Template/Test.html
@@ -280,8 +280,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.12, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.13, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
67 docs/src/Release/Changes.html
@@ -7,7 +7,7 @@
# Changes
#
# DESCRIPTION
-# Revision history for the Template Toolkit version 2.03a, detailing
+# Revision history for the Template Toolkit version 2.03b, detailing
# significant changes between versions, most recent first. Some
# way down the file you'll find a section detailing major changes from
# version 1.* to 2.* and a list of &quot;Gotchas!&quot; that you might have to
@@ -21,6 +21,71 @@
#========================================================================
#------------------------------------------------------------------------
+# Version 2.03b - 25th June 2001 ## DEVELOPER PRE-RELEASE FOR v2.04 ##
+#------------------------------------------------------------------------
+
+* Applied a patch from Craig Barratt to both the regular
+ Template::Stash and the alternate Template::Stash::Context which
+ allows array indexes into hashes and arrays (slices) in the same
+ manner as Perl. For example:
+
+ [% tt_start_tag %] keys = [ 'foo', 'bar' ]
+ vals = hash.$keys # [ hash.foo, hash.bar ]
+
+ keys = [ 2, 3, 7 ]
+ vals = list.$keys # [ list.2, list.3, list.7 ]
+ [% tt_end_tag %]
+
+* Applied another patch from Craig to Parser.pm which fixes a bug
+ relating to text strings being interpolated in a numerical context.
+ See: http://www.tt2.org/pipermail/templates/2001-April/000901.html
+
+* Applied yet another patch from Craig (&quot;Man of the Patch&quot; for v2.04 :-),
+ to fix a problem with NEXT not working inside switch:
+
+ FOREACH and WHILE now get a LOOP: label, and NEXT and LAST now
+ generate &quot;next LOOP;&quot; and &quot;last LOOP;&quot;. However, the original
+ code allows naked &quot;NEXT&quot; or &quot;LAST&quot; (which behave like STOP). I
+ didn't want to change this behavior, so NEXT and LAST only get the
+ LOOP label inside loops (except in the top-level atomexpr FOREACH
+ and atomexpr WHILE cases, which should be ok).
+
+* Applied a patch from Mark Fowler, which fixes the problem with
+ search/replace virtual methods incorrectly returning with a search
+ pattern of '0'. e.g. [% tt_start_tag %] bob = '0'; bob.replace('0', 'zero') [% tt_end_tag %]
+ now returns 'zero' instead of ''.
+
+* Applied a patch from Doug Steinwand to prevent the Stash from
+ raising undef error reporting 'Can't locate object methof &quot;bar&quot; via
+ package &quot;Foo&quot;' unless $DEBUG is enabled.
+
+* Applied a patch to the DBI plugin from Rafael Kitover which calls
+ the DBI connect_cached() method instead of connect() to allow
+ connection caching in a persistant server environment (e.g. Apache
+ mod_perl).
+
+* Changed html filter to be a dynamic filter factory, allowing the
+ 'entity' option to be set to prevent entities of the form
+ '&amp;word;' being converted to '&amp;amp;word;'
+
+ [% tt_start_tag %] FILTER html(entity = 1) [% tt_end_tag %]
+ &lt; &amp;amp; &gt; # &amp;lt; &amp;amp; &amp;gt;
+ [% tt_start_tag %] END [% tt_end_tag %]
+
+* Changed Template::Stash to propogate any object errors that
+ are references (e.g. Template::Exception objects or otherwise)
+ or string that don't look like &quot;Can't locate object method ...&quot;.
+
+* Fixed various typos in docsrc/xml/ttdocsrc with a deft:
+ s/Plugin::GD::Graphs/Plugin::GD::Graph/g;
+
+* Applied a patch from Leon Brocard to remove a suspect test from
+ t/filter.t which Chris Nandor reported as causing problems.
+
+* Added Craig's comments on replace backreferences and TT grammar to
+ TODO list.
+
+#------------------------------------------------------------------------
# Version 2.03a - 18th June 2001 ## DEVELOPER PRE-RELEASE FOR v2.04 ##
#------------------------------------------------------------------------
View
18 docs/src/Release/README.html
@@ -5,9 +5,9 @@
Template Toolkit
- Version 2.03a
+ Version 2.03b
- 18 June 2001
+ 25 June 2001
Copyright (C) 1996-2001 Andy Wardley. All Rights Reserved
Copyright (C) 1998-2001 Canon Research Centre Europe Ltd.
@@ -46,8 +46,8 @@
To install the Template Toolkit:
- tar zxf Template-Toolkit-2.03a.tar.gz
- cd Template-Toolkit-2.03a
+ tar zxf Template-Toolkit-2.03b.tar.gz
+ cd Template-Toolkit-2.03b
perl Makefile.PL
make
make test
@@ -297,19 +297,19 @@
Template-Toolkit-&lt;version&gt;.tar.gz
-where &lt;version&gt; represents the current version number, e.g. 2.03a.
+where &lt;version&gt; represents the current version number, e.g. 2.03b.
To install the Template Toolkit, unpack the distribution archive to
create an installation directory. Something like this:
- tar zxf Template-Toolkit-2.03a.tar.gz
+ tar zxf Template-Toolkit-2.03b.tar.gz
or
- gunzip Template-Toolkit-2.03a.tar.gz
- tar xf Template-Toolkit-2.03a.tar
+ gunzip Template-Toolkit-2.03b.tar.gz
+ tar xf Template-Toolkit-2.03b.tar
You can then 'cd' into the directory created,
- cd Template-Toolkit-2.03a
+ cd Template-Toolkit-2.03b
and perform the usual Perl installation procedure:
View
133 docs/src/Release/TODO.html
@@ -7,7 +7,7 @@
# TODO
#
# DESCRIPTION
-# TODO list for the Template Toolkit version 2.03a, containing
+# TODO list for the Template Toolkit version 2.03b, containing
# known bugs, limitations, planned enhancements, long term visions
# and a few whacky ideas.
#
@@ -82,6 +82,45 @@
maps to the samed compiled version) but is convenient for those times
when you know that's not going to be a problem.
+* Richard Tietjen's patch for stash replace. Allows back references
+ (e.g. $1) but it would be nice to find a rock-solid way to implement
+ it without relying on unusual ^A delimiter character.
+
+* Further to the above, Craig Barratt has this solution which will be
+ going into the next verion (2.05) unless anyone has any further
+ suggestions to make before then.
+
+ It would be great if replace handled backreferences. I don't like
+ the ^A solution since the string could contain ^A, plus it is a
+ security hole. The attempt I posted only works for up to 9
+ backreferences and doesn't handle an escaped '\$' and uses nested
+ evals:
+
+ $str =~ s{$search}{
+ my $r = $replace;
+ my @d = (0, $1, $2, $3, $4, $5, $6, $7, $8, $9);
+ $r =~ s/\$(\d+)/$d[$1]/eg;
+ $r;
+ }eg;
+
+ I wish there was a perl predefined variable array containing all
+ the backreferences (is there one?). You can avoid the hard-coded
+ limit of 9 with extra evals, and a bit of work on the re could
+ handle the escaped '\$' case, so maybe that would be good enough.
+
+* Craig also notes, in fixing the problem with NEXT not working
+ inside SWITCH (see Changes v2.04):
+
+ By the way, I came across another arcane bug:
+
+ NEXT FOREACH k = [1];
+
+ is legal syntax but is an infinite loop, since $_[0]-&gt;{ INFOR } in
+ Parser.yp is not set when the NEXT is parsed, so it generates a
+ plain &quot;next;&quot; rather than calling $factor-&gt;next(). I don't see an
+ easy, clean fix.
+
+
#------------------------------------------------------------------------
# Documentation
#------------------------------------------------------------------------
@@ -162,7 +201,8 @@
#------------------------------------------------------------------------
* Lists don't accept arbitrary expressions as elements. In other words
- you can't do this: [% tt_start_tag %] foo(bar + 1) [% tt_end_tag %]
+ you can't do this: [% tt_start_tag %] foo(bar + 1) [% tt_end_tag %]. This has been fixed in the v3
+ parser. See http://www.tt2.org/v3/
* Stas reported a problem with spacing, something like : [% tt_start_tag %] a =b+10 [% tt_end_tag %] but
I can't seem to reproduce it (or remember exactly what the problem
@@ -250,6 +290,95 @@
major one) but I haven't really considered them yet so watch this
space for details.
+* Craig Barratt reports the following:
+
+ I looked at Parse.yp to see how hard it would be to push FILTER
+ evaluation down into the expr rule, so that you could put filters
+ inside expressions (eg: using repeat() just like &amp;quot;x&amp;quot; in
+ perl). More about that later.
+
+ In browsing through Parser.yp I noticed several issues:
+
+ - The operator precedence is very different to perl, C etc.
+ For example, these expressions evaluate differently in
+ TT2 versus perl, C etc:
+
+ + &quot;1 || 0 &amp;&amp; 0&quot; evaluates to 0 in TT2 and 1 in perl or C.
+ TT2 parses it as (1||0) &amp;&amp; 0; in perl and C &amp;&amp; is higher
+ precedence than ||.
+
+ + &quot;1 + !0 + 1&quot; evaluates to 1 in TT2 and 3 in perl or C.
+ TT2 parses it as 1 + !(0 + 1); in perl and C ! is higher
+ precedence than +.
+
+ + Many other expressions parse incorrectly, but the effect
+ is benign since most rules return flat text that perl
+ correctly re-parses. Eg, 2 * 3 + 4 is incorrectly parsed
+ as (2 * (3 + 4)), but happily just the string &quot;2 * 3 + 4&quot;
+ is compiled by perl, which correctly evaluates it as
+ (2 * 3) + 4.
+
+ - There is no unary minus and the NUMBER token is signed. So you can
+ write &quot;x = -2;&quot; but not &quot;x = -y;&quot;. Moreover, &quot;x = 1 -1;&quot; is a syntax
+ error (since &quot;1 -1&quot; returns just two tokens NUMBER, NUMBER). (As a
+ workaround you can rewrite these as &quot;x = 0-y;&quot; and &quot;x = 1 - 1&quot;.)
+
+ - You cannot have expressions in lists ([..]) and function arguments.
+
+ I have modified the Parser.pm (to make NUMBER unsigned) and modified
+ Grammar.pm.skel and Parser.yp to fix most of these issues (improved
+ operator precedence, unary minus and plus), and also to allow
+ expressions in a few more places (eg: range). But the last item
+ has me stuck.
+
+ The parse rules for lists and function arguments make COMMA optional,
+ so you can equivalently write [1 2 3 4] or [1,,,,,2 3 4] or [1,2,3,4].
+ This makes it very difficult to make each term an expression, because
+ the resulting grammar has many ambiguities. For example, is [1 -1]
+ two elements [1, -1] or a single element [0]? One partial solution is
+ to move the bracketed expression rule '(' expr ')' to the term rule,
+ allowing expressions to be included via parens. But there are also
+ ambiguities, eg: does [foo (1+1)] have 2 elements or is it a function
+ call to foo?
+
+ Without allowing expressions in lists or function arguments, the unary
+ minus change I've made means that the NUMBER token is unsigned, so with
+ my changes you cannot write [-1, 2, 3]. Not a good thing.
+
+ One solution is to change the grammar so that COMMAs are required in
+ lists and arguments, but that would break several test cases and
+ probably break lots of old templates. But this might be the only
+ way to produce a grammar that is a lot more similar to perl.
+
+ Another solution is to ignore these issues altogether and use temporary
+ variables to precompute expressions that you need in lists or function
+ arguments, or use explicit lvalue assignments, eg:
+
+ foo(x + 2); becomes temp = x + 2;
+ foo(temp);
+
+ or
+
+ List = [x+1,x+2,x+4]; becomes List = [];
+ List.0 = x+1;
+ List.1 = x+2;
+ List.2 = x+4;
+
+ Both of these look ugly to me.
+
+ Back to the FILTER issues. Ultimately I'd like to be able to embed filters
+ as low precedence operators in expressions, and write:
+
+ List = [
+ &quot;foo&quot; | repeat(10),
+ &quot;bar&quot; | repeat(10)
+ ];
+
+ but I doubt there is a non-ambiguous upward compatible grammar that
+ supports this.
+
+ Comments?
+
#------------------------------------------------------------------------
# Plugins
View
4 docs/src/Tools/tpage.html
@@ -61,8 +61,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
4 docs/src/Tools/ttree.html
@@ -112,8 +112,8 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Tutorial/Datafile.html
@@ -430,7 +430,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
2  docs/src/Tutorial/Web.html
@@ -765,7 +765,7 @@
[% WRAPPER section
title="VERSION"
-%]<p>
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
</p>
[%- END %]
[% WRAPPER section
View
30 docsrc/src/Release/Changes.tt2
@@ -18,7 +18,7 @@
#========================================================================
#------------------------------------------------------------------------
-# Version 2.03b - th June 2001 ## DEVELOPER PRE-RELEASE FOR v2.04 ##
+# Version 2.03b - 25th June 2001 ## DEVELOPER PRE-RELEASE FOR v2.04 ##
#------------------------------------------------------------------------
* Applied a patch from Craig Barratt to both the regular
@@ -37,6 +37,16 @@
relating to text strings being interpolated in a numerical context.
See: http://www.tt2.org/pipermail/templates/2001-April/000901.html
+* Applied yet another patch from Craig ("Man of the Patch" for v2.04 :-),
+ to fix a problem with NEXT not working inside switch:
+
+ FOREACH and WHILE now get a LOOP: label, and NEXT and LAST now
+ generate "next LOOP;" and "last LOOP;". However, the original
+ code allows naked "NEXT" or "LAST" (which behave like STOP). I
+ didn't want to change this behavior, so NEXT and LAST only get the
+ LOOP label inside loops (except in the top-level atomexpr FOREACH
+ and atomexpr WHILE cases, which should be ok).
+
* Applied a patch from Mark Fowler, which fixes the problem with
search/replace virtual methods incorrectly returning with a search
pattern of '0'. e.g. [% bob = '0'; bob.replace('0', 'zero') %]
@@ -48,7 +58,20 @@
* Applied a patch to the DBI plugin from Rafael Kitover which calls
the DBI connect_cached() method instead of connect() to allow
- connection caching in a persistant server environemnt.
+ connection caching in a persistant server environment (e.g. Apache
+ mod_perl).
+
+* Changed html filter to be a dynamic filter factory, allowing the
+ 'entity' option to be set to prevent entities of the form
+ '&word;' being converted to '&amp;word;'
+
+ [% FILTER html(entity = 1) %]
+ < &amp; > # &lt; &amp; &gt;
+ [% END %]
+
+* Changed Template::Stash to propogate any object errors that
+ are references (e.g. Template::Exception objects or otherwise)
+ or string that don't look like "Can't locate object method ...".
* Fixed various typos in docsrc/xml/ttdocsrc with a deft:
s/Plugin::GD::Graphs/Plugin::GD::Graph/g;
@@ -56,6 +79,9 @@
* Applied a patch from Leon Brocard to remove a suspect test from
t/filter.t which Chris Nandor reported as causing problems.
+* Added Craig's comments on replace backreferences and TT grammar to
+ TODO list.
+
#------------------------------------------------------------------------
# Version 2.03a - 18th June 2001 ## DEVELOPER PRE-RELEASE FOR v2.04 ##
#------------------------------------------------------------------------
View
126 docsrc/src/Release/TODO.tt2
@@ -83,6 +83,40 @@
(e.g. $1) but it would be nice to find a rock-solid way to implement
it without relying on unusual ^A delimiter character.
+* Further to the above, Craig Barratt has this solution which will be
+ going into the next verion (2.05) unless anyone has any further
+ suggestions to make before then.
+
+ It would be great if replace handled backreferences. I don't like
+ the ^A solution since the string could contain ^A, plus it is a
+ security hole. The attempt I posted only works for up to 9
+ backreferences and doesn't handle an escaped '\$' and uses nested
+ evals:
+
+ $str =~ s{$search}{
+ my $r = $replace;
+ my @d = (0, $1, $2, $3, $4, $5, $6, $7, $8, $9);
+ $r =~ s/\$(\d+)/$d[$1]/eg;
+ $r;
+ }eg;
+
+ I wish there was a perl predefined variable array containing all
+ the backreferences (is there one?). You can avoid the hard-coded
+ limit of 9 with extra evals, and a bit of work on the re could
+ handle the escaped '\$' case, so maybe that would be good enough.
+
+* Craig also notes, in fixing the problem with NEXT not working
+ inside SWITCH (see Changes v2.04):
+
+ By the way, I came across another arcane bug:
+
+ NEXT FOREACH k = [1];
+
+ is legal syntax but is an infinite loop, since $_[0]->{ INFOR } in
+ Parser.yp is not set when the NEXT is parsed, so it generates a
+ plain "next;" rather than calling $factor->next(). I don't see an
+ easy, clean fix.
+
#------------------------------------------------------------------------
# Documentation
@@ -164,7 +198,8 @@
#------------------------------------------------------------------------
* Lists don't accept arbitrary expressions as elements. In other words
- you can't do this: [% foo(bar + 1) %]
+ you can't do this: [% foo(bar + 1) %]. This has been fixed in the v3
+ parser. See http://www.tt2.org/v3/
* Stas reported a problem with spacing, something like : [% a =b+10 %] but
I can't seem to reproduce it (or remember exactly what the problem
@@ -252,6 +287,95 @@
major one) but I haven't really considered them yet so watch this
space for details.
+* Craig Barratt reports the following:
+
+ I looked at Parse.yp to see how hard it would be to push FILTER
+ evaluation down into the expr rule, so that you could put filters
+ inside expressions (eg: using repeat() just like &quot;x&quot; in
+ perl). More about that later.
+
+ In browsing through Parser.yp I noticed several issues:
+
+ - The operator precedence is very different to perl, C etc.
+ For example, these expressions evaluate differently in
+ TT2 versus perl, C etc:
+
+ + "1 || 0 && 0" evaluates to 0 in TT2 and 1 in perl or C.
+ TT2 parses it as (1||0) && 0; in perl and C && is higher
+ precedence than ||.
+
+ + "1 + !0 + 1" evaluates to 1 in TT2 and 3 in perl or C.
+ TT2 parses it as 1 + !(0 + 1); in perl and C ! is higher
+ precedence than +.
+
+ + Many other expressions parse incorrectly, but the effect
+ is benign since most rules return flat text that perl
+ correctly re-parses. Eg, 2 * 3 + 4 is incorrectly parsed
+ as (2 * (3 + 4)), but happily just the string "2 * 3 + 4"
+ is compiled by perl, which correctly evaluates it as
+ (2 * 3) + 4.
+
+ - There is no unary minus and the NUMBER token is signed. So you can
+ write "x = -2;" but not "x = -y;". Moreover, "x = 1 -1;" is a syntax
+ error (since "1 -1" returns just two tokens NUMBER, NUMBER). (As a
+ workaround you can rewrite these as "x = 0-y;" and "x = 1 - 1".)
+
+ - You cannot have expressions in lists ([..]) and function arguments.
+
+ I have modified the Parser.pm (to make NUMBER unsigned) and modified
+ Grammar.pm.skel and Parser.yp to fix most of these issues (improved
+ operator precedence, unary minus and plus), and also to allow
+ expressions in a few more places (eg: range). But the last item
+ has me stuck.
+
+ The parse rules for lists and function arguments make COMMA optional,
+ so you can equivalently write [1 2 3 4] or [1,,,,,2 3 4] or [1,2,3,4].
+ This makes it very difficult to make each term an expression, because
+ the resulting grammar has many ambiguities. For example, is [1 -1]
+ two elements [1, -1] or a single element [0]? One partial solution is
+ to move the bracketed expression rule '(' expr ')' to the term rule,
+ allowing expressions to be included via parens. But there are also
+ ambiguities, eg: does [foo (1+1)] have 2 elements or is it a function
+ call to foo?
+
+ Without allowing expressions in lists or function arguments, the unary
+ minus change I've made means that the NUMBER token is unsigned, so with
+ my changes you cannot write [-1, 2, 3]. Not a good thing.
+
+ One solution is to change the grammar so that COMMAs are required in
+ lists and arguments, but that would break several test cases and
+ probably break lots of old templates. But this might be the only
+ way to produce a grammar that is a lot more similar to perl.
+
+ Another solution is to ignore these issues altogether and use temporary
+ variables to precompute expressions that you need in lists or function
+ arguments, or use explicit lvalue assignments, eg:
+
+ foo(x + 2); becomes temp = x + 2;
+ foo(temp);
+
+ or
+
+ List = [x+1,x+2,x+4]; becomes List = [];
+ List.0 = x+1;
+ List.1 = x+2;
+ List.2 = x+4;
+
+ Both of these look ugly to me.
+
+ Back to the FILTER issues. Ultimately I'd like to be able to embed filters
+ as low precedence operators in expressions, and write:
+
+ List = [
+ "foo" | repeat(10),
+ "bar" | repeat(10)
+ ];
+
+ but I doubt there is a non-ambiguous upward compatible grammar that
+ supports this.
+
+ Comments?
+
#------------------------------------------------------------------------
# Plugins
View
4 lib/Template.pm
@@ -39,7 +39,7 @@ use File::Path;
## This is the main version number for the Template Toolkit.
## It is extracted by ExtUtils::MakeMaker and inserted in various places.
-$VERSION = '2.03a';
+$VERSION = '2.03b';
$ERROR = '';
$DEBUG = 0;
@@ -889,7 +889,7 @@ L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
-Template Toolkit version 2.03a, released on 18 June 2001.
+Template Toolkit version 2.03b, released on 25 June 2001.
=head1 COPYRIGHT
View
4 lib/Template/Base.pm
@@ -215,8 +215,8 @@ L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
-2.14, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.15, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
=head1 COPYRIGHT
View
4 lib/Template/Config.pm
@@ -392,8 +392,8 @@ L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
-2.12, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.13, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
=head1 COPYRIGHT
View
4 lib/Template/Constants.pm
@@ -162,8 +162,8 @@ L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
-2.13, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.14, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
=head1 COPYRIGHT
View
4 lib/Template/Context.pm
@@ -1419,8 +1419,8 @@ L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
-2.19, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.20, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
=head1 COPYRIGHT
View
7 lib/Template/Directive.pm
@@ -417,7 +417,7 @@ do {
$loop_save;
\$stash->set('loop', \$list);
eval {
- while (! \$error) {
+LOOP: while (! \$error) {
$loop_set;
$block;
(\$value, \$error) = \$list->get_next();
@@ -440,7 +440,7 @@ EOF
sub next {
return <<EOF;
(\$value, \$error) = \$list->get_next();
-next;
+next LOOP;
EOF
}
@@ -518,6 +518,7 @@ sub while {
# WHILE
do {
my \$failsafe = $WHILE_MAX;
+LOOP:
while (--\$failsafe && ($expr)) {
$block
}
@@ -699,7 +700,7 @@ sub clear {
#------------------------------------------------------------------------
sub break {
- return 'last;';
+ return 'last LOOP;';
}
#------------------------------------------------------------------------
View
4 lib/Template/Document.pm
@@ -449,8 +449,8 @@ L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
-2.14, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.15, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
=head1 COPYRIGHT
View
4 lib/Template/Exception.pm
@@ -228,8 +228,8 @@ L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
-2.10, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.11, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
=head1 COPYRIGHT
View
6 lib/Template/FAQ.pod
@@ -18,7 +18,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# 2.11
+# 2.12
#
#========================================================================
@@ -202,8 +202,8 @@ L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
-2.11, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.12, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
=head1 COPYRIGHT
View
41 lib/Template/Filters.pm
@@ -45,7 +45,7 @@ $VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/);
$FILTERS = {
# static filters
- 'html' => \&html_filter,
+# 'html' => \&html_filter,
'html_para' => \&html_paragraph,
'html_break' => \&html_break,
'upper' => sub { uc $_[0] },
@@ -57,6 +57,7 @@ $FILTERS = {
$_[0] },
# dynamic filters
+ 'html' => [ \&html_filter_factory, 1 ],
'indent' => [ \&indent_filter_factory, 1 ],
'format' => [ \&format_filter_factory, 1 ],
'truncate' => [ \&truncate_filter_factory, 1 ],
@@ -196,11 +197,13 @@ sub _dump {
#------------------------------------------------------------------------
# html_filter() [% FILTER html %]
#
+# NOTE: html filter is now dynamic to allow 'entity' option.
+#
# Convert any '<', '>' or '&' characters to the HTML equivalents, '&lt;',
# '&gt;' and '&amp;', respectively.
#------------------------------------------------------------------------
-sub html_filter {
+sub html_filter_not_used {
my $text = shift;
for ($text) {
s/&/&amp;/g;
@@ -248,6 +251,36 @@ sub html_break {
#========================================================================
#------------------------------------------------------------------------
+# html_filter_factory(\%optins) [% FILTER html %]
+#
+# Convert any '<', '>' or '&' characters to the HTML equivalents, '&lt;',
+# '&gt;' and '&amp;', respectively. The 'entity' option can be set to
+# any true value to prevent entities of the form &word; being converted
+# to &amp;word;
+#------------------------------------------------------------------------
+
+sub html_filter_factory {
+ my $context = shift;
+ my $opts = @_ && ref $_[-1] eq 'HASH' ? pop @_ : { };
+ return sub {
+ my $text = shift;
+ for ($text) {
+ if ($opts->{ entity }) {
+ s/&(?!\w+;)/&amp;/g;
+ }
+ else {
+ s/&/&amp;/g;
+ }
+ s/</&lt;/g;
+ s/>/&gt;/g;
+ s/"/&quot;/g;
+ }
+ return $text;
+ };
+}
+
+
+#------------------------------------------------------------------------
# indent_filter_factory($pad) [% FILTER indent(pad) %]
#
# Create a filter to indent text by a fixed pad string or when $pad is
@@ -1174,8 +1207,8 @@ L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
-2.15, distributed as part of the
-Template Toolkit version 2.03a, released on 18 June 2001.
+2.16, distributed as part of the
+Template Toolkit version 2.03b, released on 25 June 2001.
=head1 COPYRIGHT
View
1,013 lib/Template/Grammar.pm
@@ -204,10 +204,10 @@ $STATES = [
}
},
{#State 1
- DEFAULT => -100
+ DEFAULT => -101
},
{#State 2
- DEFAULT => -109
+ DEFAULT => -110
},
{#State 3
ACTIONS => {
@@ -243,9 +243,9 @@ $STATES = [
DEFAULT => -27
},
{#State 6
- DEFAULT => -75,
+ DEFAULT => -76,
GOTOS => {
- '@4-1' => 75
+ '@5-1' => 75
}
},
{#State 7
@@ -275,7 +275,7 @@ $STATES = [
'DOT' => 88,
'ASSIGN' => 89
},
- DEFAULT => -105
+ DEFAULT => -106
},
{#State 10
DEFAULT => -15
@@ -333,7 +333,7 @@ $STATES = [
'LITERAL' => 99,
'IDENT' => 98
},
- DEFAULT => -115,
+ DEFAULT => -116,
GOTOS => {
'param' => 101,
'params' => 97,
@@ -359,7 +359,7 @@ $STATES = [
DEFAULT => -26
},
{#State 20
- DEFAULT => -99
+ DEFAULT => -100
},
{#State 21
ACTIONS => {
@@ -438,7 +438,7 @@ $STATES = [
ACTIONS => {
"(" => 117
},
- DEFAULT => -124
+ DEFAULT => -125
},
{#State 26
ACTIONS => {
@@ -460,7 +460,7 @@ $STATES = [
DEFAULT => -5
},
{#State 28
- DEFAULT => -126
+ DEFAULT => -127
},
{#State 29
ACTIONS => {
@@ -619,7 +619,7 @@ $STATES = [
'LITERAL' => 142,
'IDENT' => 140
},
- DEFAULT => -83,
+ DEFAULT => -84,
GOTOS => {
'meta' => 96,
'blockname' => 141,
@@ -630,7 +630,7 @@ $STATES = [
}
},
{#State 45
- DEFAULT => -171,
+ DEFAULT => -172,
GOTOS => {
'quoted' => 143
}
@@ -759,7 +759,7 @@ $STATES = [
ACTIONS => {
'ASSIGN' => 147
},
- DEFAULT => -108
+ DEFAULT => -109