]> Dogcows Code - chaz/p5-CGI-Ex/blobdiff - lib/CGI/Ex/Template.pod
CGI::Ex 2.11
[chaz/p5-CGI-Ex] / lib / CGI / Ex / Template.pod
index e0ea84279a47c1ebea6a2222d7291a873fd16927..f93126132525f6d91f90902d6b35e0580284b2ae 100644 (file)
@@ -18,7 +18,7 @@ CGI::Ex::Template - Fast and lightweight TT2/3 template engine
     $t->process('my/template.tt', $swap)
         || die $t->error;
 
-    ### Anything in the Template::Toolkit SYNOPSIS would fit here also
+    ### CET uses the same syntax and configuration as Template::Toolkit
 
 =head1 DESCRIPTION
 
@@ -43,6 +43,12 @@ in sync at a language level.  There already has been, and it is expected that
 there will continue to be code sharing between the two projects.  (Acutally
 I will try and keep applicable fixes in sync with TT).
 
+CGI::Ex::Template uses a recursive regex based grammar (early versions
+before the 2.10 release did not).  This allows for the embedding of opening
+and closing tags inside other tags (as in [% a = "[% 1 + 2 %]" ;  a|eval %]).
+The individual methods such as parse_expr and play_expr may be used by external
+applications to add TT style variable parsing to other applications.
+
 Most of the standard Template::Toolkit documentation covering directives,
 variables, configuration, plugins, filters, syntax, and vmethods should
 apply to CET just fine (This pod tries to explain everything - but there is
@@ -56,10 +62,10 @@ samples/benchmark/bench_template.pl was used to obtain sample numbers.
 In general the following statements are true:
 
     If you load a new Template object each time and pass a filename, CET
-    is around 4 times faster.
+    is around 3.5 times faster.
 
     If you load a new Template object and pass a string ref, CET
-    is around 3.5 times faster.
+    is around 3 times faster.
 
     If you load a new Template object and use CACHE_EXT, CET
     is around 1.5 times faster.
@@ -68,16 +74,15 @@ In general the following statements are true:
     then CET is 50% faster.
 
     If you use Template::Stash::XS with a cached in memory template,
-    then CET is about as fast.
-
-    Using TT with a compiled-in-memory template is only 33
-    faster than CET with a new object compiling each time.
+    then CET is about as fast.  But if you use CGI::Ex::Template::XS,
+    the CETX is faster still (about twice as fast as CET).
 
 It is pretty hard to beat the speed of XS stash with compiled in
 memory templates.  Many systems don't have access to those so
 CET may make more sense.  Hopefully as TT is revised, many of the CET
 speed advantages can be incorporated so that the core TT is just as
-fast or faster.
+fast or faster.  This was last updated at version 2.10 of CET and
+2.18 of TT.
 
 So should you use CGI::Ex::Template ?  Well, try it out.  It may
 give you no visible improvement.  Or it could.
@@ -102,8 +107,8 @@ commonly used public methods are listed later in this document.
 
 =item C<process>
 
-This is the main method call for staring processing.  Any errors that results in the
-template being stopped processing will be stored and available via the ->error method.
+This is the main method call for starting processing.  Any errors that result in the
+template processing being stopped will be stored and available via the ->error method.
 
 Process takes three arguments.
 
@@ -175,140 +180,298 @@ to Template::Stash::define_vmethod.
 
 =head1 TODO
 
-    Add WRAPPER config item
+    Add WRAPPER configuration item (the WRAPPER directive is supported).
 
     Add ERROR config item
 
 =head1 HOW IS CGI::Ex::Template DIFFERENT
 
-CET uses the same template syntax and configuration items
-as TT2, but the internals of CET were written from scratch.  In
-addition to this, the following is a list of some of the ways that
-configuration and syntax of CET different from that of TT.
+CET uses the same base template syntax and configuration items as TT2,
+but the internals of CET were written from scratch.  Additionally much
+of the planned TT3 syntax is supported.  The following is a list of
+some of the ways that the configuration and syntax of CET are
+different from that of TT2.  Note: items that are planned to work in
+TT3 are marked with (TT3).
 
 =over 4
 
-Numerical hash keys work [% a = {1 => 2} %]
+=item Numerical hash keys work
+
+    [% a = {1 => 2} %]
+
+=item Quoted hash key interpolation is fine
+
+    [% a = {"$foo" => 1} %]
+
+=item Multiple ranges in same constructor
+
+    [% a = [1..10, 21..30] %]
+
+=item Constructor types can call virtual methods. (TT3)
+
+    [% a = [1..10].reverse %]
+
+    [% "$foo".length %]
+
+    [% 123.length %]   # = 3
+
+    [% 123.4.length %]  # = 5
+
+    [% -123.4.length %] # = -5 ("." binds more tightly than "-")
+
+    [% (a ~ b).length %]
+
+    [% "hi".repeat(3) %] # = hihihi
+
+    [% {a => b}.size %] # = 1
+
+=item The "${" and "}" variable interpolators can contain expressions,
+not just variables.
+
+    [% [0..10].${ 1 + 2 } %] # = 4
+
+    [% {ab => 'AB'}.${ 'a' ~ 'b' } %] # = AB
+
+    [% color = qw/Red Blue/; FOR [1..4] ; color.${ loop.index % color.size } ; END %]
+      # = RedBlueRedBlue
+
+=item You can use regular expression quoting.
+
+    [% "foo".match( /(F\w+)/i ).0 %] # = foo
+
+=item Tags can be nested.
+
+    [% f = "[% (1 + 2) %]" %][% f|eval %] # = 3
+
+=item Arrays can be accessed with non-integer numbers.
+
+    [% [0..10].${ 2.3 } %] # = 3
+
+=item Reserved names are less reserved. (TT3)
+
+    [% GET GET %] # gets the variable named "GET"
+
+    [% GET $GET %] # gets the variable who's name is stored in "GET"
+
+=item Filters and SCALAR_OPS are interchangeable. (TT3)
+
+    [% a | length %]
+
+    [% b . lower %]
+
+=item Pipe "|" can be used anywhere dot "." can be and means to call
+the virtual method. (TT3)
+
+    [% a = {size => "foo"} %][% a.size %] # = foo
+
+    [% a = {size => "foo"} %][% a|size %] # = 1 (size of hash)
+
+=item Pipe "|" and "." can be mixed. (TT3)
+
+    [% "aa" | repeat(2) . length %] # = 4
 
-Quoted hash key interpolation is fine [% a = {"$foo" => 1} %]
+=item Added V2PIPE configuration item
 
-Multiple ranges in same constructor [% a = [1..10, 21..30] %]
+Restores the behavior of the pipe operator to be
+compatible with TT2.
 
-Constructor types can call virtual methods
+With V2PIPE = 1
 
-   [% a = [1..10].reverse %]
+    [% PROCESS a | repeat(2) %] # = value of block or file a repeated twice
 
-   [% "$foo".length %]
+With V2PIPE = 0 (default)
 
-   [% 123.length %]   # = 3
+    [% PROCESS a | repeat(2) %] # = process block or file named a ~ a
 
-   [% 123.4.length %]  # = 5
+=item Added Virtual Object Namespaces. (TT3)
 
-   [% -123.4.length %] # = -5 ("." binds more tightly than "-")
+The Text, List, and Hash types give direct access
+to virtual methods.
 
-   [% (a ~ b).length %]
+    [% a = "foobar" %][% Text.length(a) %] # = 6
 
-   [% "hi".repeat(3) %]
+    [% a = [1 .. 10] %][% List.size(a) %] # = 10
 
-   [% {a => b}.size %]
+    [% a = {a=>"A", b=>"B"} ; Hash.size(a) %] = 2
 
-Reserved names are less reserved
+    [% foo = {a => 1, b => 2}
+       | Hash.keys
+       | List.join(", ") %] # = a, b
 
-   [% GET GET %] # gets the variable named "GET"
+=item Added "fmt" scalar, list, and hash virtual methods.
 
-   [% GET $GET %] # gets the variable who's name is stored in "GET"
+    [% list.fmt("%s", ", ") %]
 
-Filters and SCALAR_OPS are interchangeable.
+    [% hash.fmt("%s => %s", "\n") %]
 
-   [% a | length %]
+=item Whitespace is less meaningful. (TT3)
 
-   [% b . lower %]
+    [% 2-1 %] # = 1 (fails in TT2)
 
-Pipe "|" can be used anywhere dot "." can be and means to call
-the virtual method.
+=item Added pow operator.
 
-   [% a = {size => "foo"} %][% a.size %] # = foo
+    [% 2 ** 3 %] [% 2 pow 3 %] # = 8 8
 
-   [% a = {size => "foo"} %][% a|size %] # = 1 (size of hash)
+=item Added self modifiers (+=, -=, *=, /=, %=, **=, ~=). (TT3)
 
-Pipe "|" and "." can be mixed.
+    [% a = 2;  a *= 3  ; a %] # = 6
+    [% a = 2; (a *= 3) ; a %] # = 66
 
-   [% "aa" | repeat(2) . length %] # = 4
+=item Added pre and post increment and decrement (++ --). (TT3)
 
-Whitespace is less meaningful.
+    [% ++a ; ++a %] # = 12
+    [% a-- ; a-- %] # = 0-1
 
-   [% 2-1 %] # = 1 (fails in TT)
+=item Added qw// contructor. (TT3)
 
-Added pow operator.
+    [% a = qw(a b c); a.1 %] # = b
 
-   [% 2 ** 3 %] [% 2 pow 3 %] # = 8 8
+    [% qw/a b c/.2 %] # = c
 
-FOREACH variables can be nested
+=item Added regex contructor. (TT3)
 
-   [% FOREACH f.b = [1..10] ; f.b ; END %]
+    [% "FOO".match(/(foo)/i).0 %] # = FOO
 
-   Note that nested variables are subject to scoping issues.
-   f.b will not be reset to its value before the FOREACH.
+    [% a = /(foo)/i; "FOO".match(a).0 %] # = FOO
 
-Post operative directives can be nested.
+=item Allow for scientific notation. (TT3)
 
-   [% one IF two IF three %]
+    [% a = 1.2e-20 %]
 
-   same as
+    [% 123.fmt('%.3e') %] # = 1.230e+02
 
-   [% IF three %][% IF two %][% one %][% END %][% END %]
+=item Allow for hexidecimal input. (TT3)
 
+    [% a = 0xff0000 %][% a %] # = 16711680
 
-   [% a = [[1..3], [5..7]] %][% i FOREACH i = j FOREACH j = a %] # = 123567
+    [% a = 0xff2 / 0xd; a.fmt('%x') %] # = 13a
 
-CATCH blocks can be empty.
+=item FOREACH variables can be nested.
 
-CET does not generate Perl code.  It generates an "opcode" tree.
+    [% FOREACH f.b = [1..10] ; f.b ; END %]
 
-CET uses storable for its compiled templates.  If EVAL_PERL is off,
-CET will not eval_string on ANY piece of information.
+Note that nested variables are subject to scoping issues.
+f.b will not be reset to its value before the FOREACH.
 
-There is no context.  CET provides a context object that mimics the
-Template::Context interface for use by some TT filters, eval perl
-blocks, and plugins.
+=item Post operative directives can be nested. (TT3)
 
-There is no stash.  CET only supports the variables passed in
-VARIABLES, PRE_DEFINE, and those passed to the process method.  CET
-provides a stash object that mimics the Template::Stash interface for
-use by some TT filters, eval perl blocks, and plugins.
+Andy Wardley calls this side-by-side effect notation.
 
-There is no provider.  CET uses the load_parsed_tree method to get and
-cache templates.
+    [% one IF two IF three %]
 
-There is no grammar.  CET has its own built in grammar system.
+    same as
 
-There is no VIEW directive.
+    [% IF three %][% IF two %][% one %][% END %][% END %]
 
-There are no references.  (There was in initial beta tests, but it was decided
-to remove the little used feature).
 
-The DEBUG directive only understands DEBUG_DIRS (8) and DEBUG_UNDEF (2).
+    [% a = [[1..3], [5..7]] %][% i FOREACH i = j FOREACH j = a %] # = 123567
 
-When debug dirs is on, directives on different lines separated by colons show the line they
-are on rather than a general line range.
+=item Semi-colons on directives in the same tag are optional. (TT3)
 
-There is no ANYCASE configuration item.  There was in initial beta tests, but it
-was dropped in favor of consistent parsing syntax.
+    [% SET a = 1
+       GET a
+     %]
 
-There is no V1DOLLAR configuration item.  This is a TT version 1 compatibility item and
-is not available in CET.
+    [% FOREACH i = [1 .. 10]
+         i
+       END %]
+
+Note: a semi-colon is still required in front of any block directive
+that can be used as a post-operative directive.
+
+    [% 1 IF 0
+       2 %]   # prints 2
+
+    [% 1; IF 0
+       2
+       END %] # prints 1
+
+=item CATCH blocks can be empty.
+
+TT2 requires them to contain something.
+
+=item Added a DUMP directive.
+
+Used for Data::Dumpering the passed variable or expression.
+
+   [% DUMP a.a %]
+
+=item Added CONFIG directive.
+
+   [% CONFIG
+        ANYCASE   => 1
+        PRE_CHOMP => '-'
+   %]
+
+=item CET does not generate Perl code.
+
+It generates an "opcode" tree.  The opcode tree is an arrayref
+of scalars and array refs nested as deeply as possible.  This "simple"
+structure could be shared TT implementations in other languages
+via JSON or YAML.
+
+=item CET uses storable for its compiled templates.
+
+If EVAL_PERL is off, CET will not eval_string on ANY piece of information.
+
+=item There is eval_filter and MACRO recursion protection
+
+You can control the nested nature of eval_filter and MACRO
+recursion using the MAX_EVAL_RECURSE and MAX_MACRO_RECURSE
+configuration items.
+
+=item There is no context.
+
+CET provides a context object that mimics the Template::Context
+interface for use by some TT filters, eval perl blocks, views,
+and plugins.
+
+=item There is no stash.
+
+Well there is but it isn't an object.
+
+CET only supports the variables passed in VARIABLES, PRE_DEFINE, and
+those passed to the process method.  CET provides a stash object that
+mimics the Template::Stash interface for use by some TT filters, eval
+perl blocks, and plugins.
+
+=item There is no provider.
+
+CET uses the load_parsed_tree method to get and cache templates.
+
+=item There is no parser/grammar.
+
+CET has its own built-in recursive regex based parser and grammar system.
+
+CET can actually be substituted in place of the native Template::Parser and
+Template::Grammar in TT by using the Template::Parser::CET module.  This
+module uses the output of parse_tree to generate a TT style compiled perl
+document.
+
+=item The DEBUG directive is more limited.
+
+It only understands DEBUG_DIRS (8) and DEBUG_UNDEF (2).
+
+=item CET has better line information
+
+When debug dirs is on, directives on different lines separated
+by colons show the line they are on rather than a general line range.
+
+Parse errors actually know what line and character they occured at.
 
 =back
 
 =head1 VARIABLES
 
-This section discusses how to use variables and expressions in the TT mini-language.
+This section discusses how to use variables and expressions in the TT
+mini-language.
 
-A variable is the most simple construct to insert into the TT mini language.  A variable
-name will look for the matching value inside CGI::Ex::Templates internal stash of variables
-which is essentially a hash reference.  This stash is initially populated by either passing
-a hashref as the second argument to the process method, or by setting the "VARIABLES" or
-"PRE_DEFINE" configuration variables.
+A variable is the most simple construct to insert into the TT mini
+language.  A variable name will look for the matching value inside
+CGI::Ex::Templates internal stash of variables which is essentially a
+hash reference.  This stash is initially populated by either passing a
+hashref as the second argument to the process method, or by setting
+the "VARIABLES" or "PRE_DEFINE" configuration variables.
 
     ### some sample variables
     my %vars = (
@@ -333,10 +496,11 @@ a hashref as the second argument to the process method, or by setting the "VARIA
     ### pass the variables during object creation (will be available to every process call)
     my $cet = CGI::Ex::Template->new(VARIABLES => \%vars);
 
-=head1 GETTING VARIABLES
+=head2 GETTING VARIABLES
 
-Once you have variables defined, they can be used directly in the template by using their name
-in the stash.  Or by using the GET directive.
+Once you have variables defined, they can be used directly in the
+template by using their name in the stash.  Or by using the GET
+directive.
 
     [% foo %]
     [% one %]
@@ -348,20 +512,22 @@ Would print when processed:
     1.0
     bar
 
-To access members of a hashref or an arrayref, you can chain together the names using a ".".
+To access members of a hashref or an arrayref, you can chain together
+the names using a ".".
 
     [% some_data.a %]
-    [% my_list.0] [% my_list.1 %]
+    [% my_list.0] [% my_list.1 %] [% my_list.-1 %]
     [% some_data.c.2 %]
 
 Would print:
 
     A
-    20 21
+    20 21 50
     4
 
-If the value of a variable is a code reference, it will be called.  You can add a set of parenthesis
-and arguments to pass arguments.  Arguments are variables and can be as complex as necessary.
+If the value of a variable is a code reference, it will be called.
+You can add a set of parenthesis and arguments to pass arguments.
+Arguments are variables and can be as complex as necessary.
 
     [% some_code %]
     [% some_code() %]
@@ -373,23 +539,26 @@ Would print:
     You passed me ().
     You passed me ().
     You passed me (bar).
-    You passed me (1, 2, 3).
+    You passed me (1.0, 2, 3).
 
-If the value of a variable is an object, methods can be called using the "." operator.
+If the value of a variable is an object, methods can be called using
+the "." operator.
 
     [% cet %]
 
-    [% cet.dump_parse('1 + 2').replace('\s+', ' ') %]
+    [% cet.dump_parse_expr('1 + 2').replace('\s+', ' ') %]
 
 Would print something like:
 
     CGI::Ex::Template=HASH(0x814dc28)
 
-    $VAR1 = [ \[ '+', '1', '2' ], 0 ];
+    $VAR1 = [ [ undef, '+', '1', '2' ], 0 ];
 
-Each type of data has virtual methods associated with them.  Virtual methods
-allow for access to common functions.  For the full list of built in virtual
-methods, please see the section titled VIRTUAL METHODS
+Each type of data (string, array and hash) have virtual methods
+associated with them.  Virtual methods allow for access to functions
+that are commonly used on those types of data.  For the full list of
+built in virtual methods, please see the section titled VIRTUAL
+METHODS
 
     [% foo.length %]
     [% my_list.size %]
@@ -401,9 +570,10 @@ Would print:
     31
     3 | 1 | 4 | 5 | 9
 
-It is also possible to "interpolate" variable names using a "$".  This allows for storing
-the name of a variable inside another variable.  If a variable name is a little
-more complex, it can be embedded inside of "${" and "}".
+It is also possible to "interpolate" variable names using a "$".  This
+allows for storing the name of a variable inside another variable.  If
+a variable name is a little more complex it can be embedded inside of
+"${" and "}".
 
     [% $vname %]
     [% ${vname} %]
@@ -419,10 +589,24 @@ Would print:
     3234
     3234
 
+In CET it is also possible to embed any expression (non-directive) in
+"${" and "}" and it is possible to use non-integers for array access.
+(This is not available in TT2)
+
+    [% ['a'..'z'].${ 2.3 } %]
+    [% {ab => 'AB'}.${ 'a' ~ 'b' } %]
+    [% color = qw/Red Blue/; FOR [1..4] ; color.${ loop.index % color.size } ; END %]
+
+Would print:
+
+    c
+    AB
+    RedBlueRedBlue
+
 =head2 SETTING VARIABLES.
 
-To define variables during processing, you can use the = operator.  In most cases
-this is the same as using the SET directive.
+To define variables during processing, you can use the = operator.  In
+most cases this is the same as using the SET directive.
 
     [% a = 234 %][% a %]
     [% SET b = "Hello" %][% b %]
@@ -445,7 +629,7 @@ Would print:
     2
     val1 val2
 
-It is possible to set multiple values at the same time.
+It is possible to set multiple values in the same SET directive.
 
     [% SET a = 'A'
            b = 'B'
@@ -474,10 +658,11 @@ Would print
 
 =head1 LITERALS AND CONSTRUCTORS
 
-The following are the types of literals allowed in CET.  They can be used as arguments
-to functions, in place of variables in directives, and in place of variables in expressions.
-
-In CET it is also possible to call virtual methods on literal values.
+The following are the types of literals (numbers and strings) and
+constructors (hash and array constructs) allowed in CET.  They can be
+used as arguments to functions, in place of variables in directives,
+and in place of variables in expressions.  In CET it is also possible
+to call virtual methods on literal values.
 
 =over 4
 
@@ -488,60 +673,98 @@ In CET it is also possible to call virtual methods on literal values.
     [% pi = 3.14159 %]   Sets the value of the variable.
     [% 3.13159.length %] Prints 7 (the string length of the number)
 
+Scientific notation is supported.
 
-=item Single quoted string.
+    [% 314159e-5 + 0 %]      Prints 3.14159.
+
+    [% .0000001.fmt('%.1e') %]  Prints 1.0e-07
+
+Hexidecimal input is also supported.
+
+    [% 0xff + 0 %]    Prints 255
+
+    [% 48875.fmt('%x') %]  Prints beeb
+
+=item Single quoted strings.
 
 Returns the string.  No variable interpolation happens.
 
     [% 'foobar' %]          Prints "foobar".
-    [% '$foo\n' %]          Prints "$foo\\n".  # the \\n is a literal "\" and a "\n"
+    [% '$foo\n' %]          Prints "$foo\\n".  # the \\n is a literal "\" and an "n"
     [% 'That\'s nice' %]    Prints "That's nice".
     [% str = 'A string' %]  Sets the value of str.
     [% 'A string'.split %]  Splits the string on ' ' and returns the list.
 
 Note: virtual methods can only be used on literal strings in CET, not in TT.
 
-=item Double quoted string.
+You may also embed the current tags in strings (CET only).
+
+    [% '[% 1 + 2 %]' | eval %]  Prints "3"
+
+=item Double quoted strings.
 
 Returns the string.  Variable interpolation happens.
 
     [% "foobar" %]                   Prints "foobar".
     [% "$foo"   %]                   Prints "bar" (assuming the value of foo is bar).
-    [% "${foo}  %]                   Prints "bar" (assuming the value of foo is bar).
+    [% "${foo}" %]                   Prints "bar" (assuming the value of foo is bar).
     [% "foobar\n" %]                 Prints "foobar\n".  # the \n is a newline.
     [% str = "Hello" %]              Sets the value of str.
     [% "foo".replace('foo','bar') %] Prints "bar".
 
 Note: virtual methods can only be used on literal strings in CET, not in TT.
 
-=item Array Constructor.
+You may also embed the current tags in strings (CET only).
+
+    [% "[% 1 + 2 %]" | eval %]  Prints "3"
+
+=item Array Constructs.
 
     [% [1, 2, 3] %]               Prints something like ARRAY(0x8309e90).
-    [% [4, 5, 6].size %]          Prints 3.
-    [% [7, 8, 9].reverse.0 %]     Prints 9.
     [% array1 = [1 .. 3] %]       Sets the value of array1.
     [% array2 = [foo, 'a', []] %] Sets the value of array2.
+    [% [4, 5, 6].size %]          Prints 3.
+    [% [7, 8, 9].reverse.0 %]     Prints 9.
+
+Note: virtual methods can only be used on array contructs in CET, not in TT.
+
+=item Quoted Array Constructs.
 
-Note: virtual methods can only be used on array contructors in CET, not in TT.
+    [% qw/1 2 3/ %]                Prints something like ARRAY(0x8309e90).
+    [% array1 = qw{Foo Bar Baz} %] Sets the value of array1.
+    [% qw[4 5 6].size %]           Prints 3.
+    [% qw(Red Blue).reverse.0 %]   Prints Blue.
 
-=item Hash Constructor.
+Note: this works in CET and is planned for TT3.
+
+=item Hash Constructs.
 
     [% {foo => 'bar'} %]                 Prints something like HASH(0x8305880)
+    [% hash = {foo => 'bar', c => {}} %] Sets the value of hash.
     [% {a => 'A', b => 'B'}.size %]      Prints 2.
     [% {'a' => 'A', 'b' => 'B'}.size %]  Prints 2.
-    [% hash = {foo => 'bar', c => {}} %] Sets the value of hash.
+    [% name = "Tom" %]
+    [% {Tom => 'You are Tom',
+        Kay => 'You are Kay'}.$name %]   Prints You are Tom
+
+Note: virtual methods can only be used on hash contructs in CET, not in TT.
 
-Note: virtual methods can only be used on hash contructors in CET, not in TT.
+=item Regex Constructs.
+
+    [% /foo/ %]                              Prints (?-xism:foo)
+    [% a = /(foo)/i %][% "FOO".match(a).0 %] Prints FOO
+
+Note: this works in CET and is planned for TT3.
 
 =head1 EXPRESSIONS
 
-Expressions are one or more variables or literals joined together
+Expressions are one or more variables or literals joined together with
 operators.  An expression can be used anywhere a variable can be used
-with the exception of the variable name of SET, and the filename of
-PROCESS, INCLUDE, WRAPPER, and INSERT.
+with the exception of the variable name in the SET directive, and the
+filename of PROCESS, INCLUDE, WRAPPER, and INSERT.
 
-The following section shows some samples of expressions.  For a full list
-of available operators, please see the section titled OPERATORS.
+The following section shows some samples of expressions.  For a full
+list of available operators, please see the section titled OPERATORS.
 
     [% 1 + 2 %]           Prints 3
     [% 1 + 2 * 3 %]       Prints 7
@@ -563,13 +786,16 @@ the "|" means to always call the virtual method or filter rather than
 looking in the hashref for a key by that name, or trying to call that
 method on the object.  This is similar to how TT3 will function.
 
+Virtual methods are also made available via Virtual Objects which
+are discussed in a later section.
+
 =head2 SCALAR VIRTUAL METHODS AND FILTERS
 
-The following is the list of builtin virtual methods and filters
-that can be called on scalar data types.  In CET and TT3, filters and
-virtual methods are more closely related.  In general anywhere a
-virtual method can be used a filter can be used also - and vice versa
-- all scalar virtual methods can be used as filters.
+The following is the list of builtin virtual methods and filters that
+can be called on scalar data types.  In CET and TT3, filters and
+virtual methods are more closely related than in TT2.  In general
+anywhere a virtual method can be used a filter can be used also - and
+likewise all scalar virtual methods can be used as filters.
 
 In addition to the filters listed below, CET will automatically load
 Template::Filters and use them if Template::Toolkit is installed.
@@ -578,8 +804,18 @@ In addition to the scalar virtual methods, any scalar will be
 automatically converted to a single item list if a list virtual method
 is called on it.
 
+Scalar virtual methods are also available through the "Text" virtual
+object (except for true filters such as eval and redirect).
+
 =over 4
 
+=item '0'
+
+    [% item = 'foo' %][% item.0 %] Returns foo.
+
+Allows for scalars to mask as arrays (scalars already will, but this
+allows for more direct access).
+
 =item chunk
 
     [% item.chunk(60).join("\n") %] Split string up into a list of chunks of text 60 chars wide.
@@ -600,9 +836,13 @@ is called on it.
 
 =item eval
 
-    [% item.eval %] Process the string as though it was a template.  This will start the parsing
-    engine and will use the same configuration as the current process.  CET is several times
-    faster at doing this than TT is and is considered acceptable.
+    [% item.eval %]
+
+Process the string as though it was a template.  This will start the parsing
+engine and will use the same configuration as the current process.  CET is several times
+faster at doing this than TT is and is considered acceptable.
+
+This is a filter and is not available via the Text virtual object.
 
 =item evaltt
 
@@ -612,10 +852,23 @@ is called on it.
 
     Same as the redirect filter.
 
+=item fmt
+
+    [% item.fmt('%d') %]
+    [% item.fmt('%6s') %]
+    [% item.fmt('%*s', 6) %]
+
+Similar to format.  Returns a string formatted with the passed pattern.  Default pattern is %s.
+
 =item format
 
-    [% item.format('%d') %] Print the string out in the specified format.  Each line is
-    processed separately.
+    [% item.format('%d') %]
+    [% item.format('%6s') %]
+    [% item.format('%*s', 6) %]
+
+Print the string out in the specified format.  It is similar to
+the "fmt" virtual method, except that the item is split on newline and each line is
+processed separately.
 
 =item hash
 
@@ -625,6 +878,10 @@ is called on it.
 
     [% item.html %] Performs a very basic html encoding (swaps out &, <, > and " for the html entities)
 
+=item int
+
+    [% item.int %] Return the integer portion of the value (0 if none).
+
 =item lcfirst
 
     [% item.lcfirst %] Capitalize the leading letter.
@@ -633,6 +890,10 @@ is called on it.
 
     [% item.length %] Return the length of the string.
 
+=item list
+
+    [% item.list %] Returns a list with a single value of the item.
+
 =item lower
 
     [% item.lower %] Return a lower-casified string.
@@ -643,18 +904,35 @@ is called on it.
 
     [% item.match("(\w+) (\w+)", 1) %] Same as before - but match globally.
 
+In CGI::Ex::Template and TT3 you can use regular expressions notation as well.
+
+    [% item.match( /(\w+) (\w+)/ ) %] Same as before.
+
+    [% item.match( m{(\w+) (\w+)} ) %] Same as before.
+
 =item null
 
     [% item.null %] Do nothing.
 
+=item rand
+
+    [% item = 10; item.rand %] Returns a number greater or equal to 0 but less than 10.
+    [% 1.rand %]
+
+Note: This filter is not available as of TT2.15.
+
 =item remove
 
-    [% item.remove("\s+") %] Same as remove - but is global and replaces with nothing.
+    [% item.remove("\s+") %] Same as replace - but is global and replaces with nothing.
 
 =item redirect
 
-    [% item.redirect("output_file.html") %] - Writes the contents out to the specified file.  The filename
-    must be relative to the OUTPUT_PATH configuration variable and the OUTPUT_PATH variable must be set.
+    [% item.redirect("output_file.html") %]
+
+Writes the contents out to the specified file.  The filename
+must be relative to the OUTPUT_PATH configuration variable and the OUTPUT_PATH variable must be set.
+
+This is a filter and is not available via the Text virtual object.
 
 =item repeat
 
@@ -666,19 +944,27 @@ is called on it.
 
     [% item.replace("\s+", "&nbsp;") %] Globally replace all space with &nbsp;
 
-    [% item.replace("foo", "bar", 0) Replace the first instance of foo with bar.
+    [% item.replace("foo", "bar", 0) %] Replace only the first instance of foo with bar.
 
     [% item.replace("(\w+)", "($1)") %] Surround all words with parenthesis.
 
+In CGI::Ex::Template and TT3 you may also use normal regular expression notation.
+
+    [% item.replace(/(\w+)/, "($1)") %] Same as before.
+
 =item search
 
-    [% item.search("(\w+)" %] Tests if the given pattern is in the string.
+    [% item.search("(\w+)") %] Tests if the given pattern is in the string.
+
+In CGI::Ex::Template and TT3 you may also use normal regular expression notation.
+
+    [% item.search(/(\w+)/, "($1)") %] Same as before.
 
 =item size
 
     [% item.size %] Always returns 1.
 
-=item split    => \&vmethod_split,
+=item split
 
     [% item.split %] Returns an arrayref from the item split on " "
 
@@ -686,6 +972,10 @@ is called on it.
 
     [% item.split("\s+", 3) %] Returns an arrayref from the item split on /\s+/ splitting until 3 elements are found.
 
+In CGI::Ex::Template and TT3 you may also use normal regular expression notation.
+
+    [% item.split( /\s+/, 3 ) %] Same as before.
+
 =item stderr
 
     [% item.stderr %] Print the item to the current STDERR handle.
@@ -712,16 +1002,34 @@ is called on it.
 
     [% item.uri %] Perform a very basic URI encoding.
 
+=item url
+
+    [% item.url %] Perform a URI encoding - but some characters such
+                   as : and / are left intact.
+
 =back
 
 =head2 LIST VIRTUAL METHODS
 
-=over 4
-
 The following methods can be called on an arrayref type data structures (scalar
 types will automatically promote to a single element list and call these methods
 if needed):
 
+Additionally, list virtual methods can be accessed via the List
+Virtual Object.
+
+=over 4
+
+=item fmt
+
+    [% mylist.fmt('%s', ', ') %]
+    [% mylist.fmt('%6s', ', ') %]
+    [% mylist.fmt('%*s', ', ', 6) %]
+
+Passed a pattern and an string to join on.  Returns a string of the values of the list
+formatted with the passed pattern and joined with the passed string.
+Default pattern is %s and the default join string is a space.
+
 =item first
 
     [% mylist.first(3) %]  Returns a list of the first 3 items in the list.
@@ -768,6 +1076,17 @@ if needed):
 
     [% mylist.push(23) %] Adds an element to the end of the arrayref (the stash is modified).
 
+=item pick
+
+    [% mylist.pick %] Returns a random item from the list.
+    [% ['a' .. 'z'].pick %]
+
+An additional numeric argument is how many items to return.
+
+    [% ['a' .. 'z'].pick(8).join('') %]
+
+Note: This filter is not available as of TT2.15.
+
 =item reverse
 
     [% mylist.reverse %] Returns the list in reverse order.
@@ -810,8 +1129,21 @@ if needed):
 
 The following methods can be called on hash type data structures:
 
+Additionally, list virtual methods can be accessed via the Hash
+Virtual Object.
+
 =over 4
 
+=item fmt
+
+    [% myhash.fmt('%s => %s', "\n") %]
+    [% myhash.fmt('%4s => %5s', "\n") %]
+    [% myhash.fmt('%*s => %*s', "\n", 4, 5) %]
+
+Passed a pattern and an string to join on.  Returns a string of the key/value pairs
+of the hash formatted with the passed pattern and joined with the passed string.
+Default pattern is "%s\t%s" and the default join string is a newline.
+
 =item defined
 
     [% myhash.defined('a') %]  Checks if a is defined in the hash.
@@ -820,6 +1152,9 @@ The following methods can be called on hash type data structures:
 
     [% myhash.delete('a') %]  Deletes the item from the hash.
 
+Unlink Perl the value is not returned.  Multiple values may be passed
+and represent the keys to be deleted.
+
 =item each
 
     [% myhash.each.join(", ") %]  Turns the contents of the hash into a list - subject
@@ -837,6 +1172,14 @@ The following methods can be called on hash type data structures:
 
     [% myhash.import(hash2) %]  Overlays the keys of hash2 over the keys of myhash.
 
+=item item
+
+    [% myhash.item(key) %] Returns the hashes value for that key.
+
+=item items
+
+    [% myhash.items %] Returns a list of the key and values (flattened hash)
+
 =item keys
 
     [% myhash.keys.join(', ') %] Returns an arrayref of the keys of the hash.
@@ -868,14 +1211,100 @@ The following methods can be called on hash type data structures:
 
 =back
 
+=head1 VIRTUAL OBJECTS
+
+TT3 has a concept of Text, List, and Hash virtual objects which provide
+direct access to the scalar, list, and hash virtual methods.  In the TT3
+engine this will allow for more concise generated code.  Because CET does
+not generated perl code to be executed later, CET provides for these virtual
+objects but does so as more of a namespace (using the methods does not
+provide a speed optimization in your template - just may help clarify things).
+
+    [% a = "foo"; a.length %] => 3
+
+    [% a = "foo"; Text.length(a) %] => 3
+
+    [% a = Text.new("foo"); a.length %] => 3
+
+
+    [% a = [1 .. 30]; a.size %] => 30
+
+    [% a = [1 .. 30]; List.size(a) %] => 30
+
+    [% a = List.new(1 .. 30); a.size %] => 30
+
+
+    [% a = {a => 1, b => 2}; a.size %] => 2
+
+    [% a = {a => 1, b => 2}; Hash.size(a) %] => 2
+
+    [% a = Hash.new({a => 1, b => 2}); a.size %] => 2
+
+    [% a = Hash.new(a => 1, b => 2); a.size %] => 2
+
+    [% a = Hash.new(a = 1, b = 2); a.size %] => 2
+
+    [% a = Hash.new('a', 1, 'b', 2); a.size %] => 2
+
+One limitation is that if you pass a key named "Text",
+"List", or "Hash" in your variable stash - the corresponding
+virtual object will be hidden.
+
+Additionally, you can use all of the Virtual object methods with
+the pipe operator.
+
+    [% {a => 1, b => 2}
+       | Hash.keys
+       | List.join(", ") %] => a, b
+
+Again, there aren't any speed optimizations to using the virtual
+objects in CET, but it can help clarify the intent in some cases.
+
+Note: these aren't really objects.  All of the "virtual objects" are
+references to the $SCALAR_OPS, $LIST_OPS, and $HASH_OPS hashes
+found in the $VOBJS hash of CGI::Ex::Template.
+
 =head1 DIRECTIVES
 
-This section contains the alphabetical list of DIRECTIVES available
-in the TT language.  DIRECTIVES are the "functions" and control
-structures that implement the Template Toolkit mini-language.  For
-further discussion and examples, please refer to the TT directives
-documentation.
+This section contains the alphabetical list of DIRECTIVES available in
+the TT language.  DIRECTIVES are the "functions" and control
+structures of the Template Toolkit mini-language.  For further
+discussion and examples beyond what is listed below, please refer to
+the TT directives documentation.
+
+    [% IF 1 %]One[% END %]
+    [% FOREACH a = [1 .. 3] %]
+        a = [% a %]
+    [% END %]
+
+    [% SET a = 1 %][% SET a = 2 %][% GET a %]
 
+Multiple directives can be inside the same set of '[%' and '%]' tags
+as long as they are separated by space or semi-colons (;).  Any block
+directive that can also be used as a post-operative directive (such as
+IF, WHILE, FOREACH, UNLESS, FILTER, and WRAPPER) must be separated
+from preceding directives with a semi-colon if it is being used as a
+block directive.  It is more safe to always use a semi-colon.  Note:
+separating by space is only available in CET but is a planned TT3
+feature.
+
+    [% SET a = 1 ; SET a = 2 ; GET a %]
+    [% SET a = 1
+       SET a = 2
+       GET a
+     %]
+
+    [% GET 1
+         IF 0   # is a post-operative
+       GET 2 %] # prints 2
+
+    [% GET 1;
+       IF 0     # it is block based
+         GET 2
+       END
+     %]         # prints 1
+
+The following is the list of directives.
 
 =over 4
 
@@ -933,6 +1362,36 @@ Clears any of the content currently generated in the innermost block
 or template.  This can be useful when used in conjunction with the TRY
 statement to clear generated content if an error occurs later.
 
+=item C<CONFIG>
+
+Allow for changing the value of some compile time and runtime configuration
+options.
+
+    [% CONFIG
+        ANYCASE   => 1
+        PRE_CHOMP => '-'
+    %]
+
+The following compile time configuration options may be set:
+
+    ANYCASE
+    INTERPOLATE
+    PRE_CHOMP
+    POST_CHOMP
+    V1DOLLAR
+    V2PIPE
+
+The following runtime configuration options may be set:
+
+    DUMP
+
+If non-named parameters as passed, they will show the current configuration:
+
+   [% CONFIG ANYCASE, PRE_CHOMP %]
+
+   CONFIG ANYCASE = undef
+   CONFIG PRE_CHOMP = undef
+
 =item C<DEBUG>
 
 Used to reset the DEBUG_FORMAT configuration variable, or to turn
@@ -954,13 +1413,15 @@ defined or was zero length.
 
 =item C<DUMP>
 
-This is not provided in TT.  DUMP inserts a Data::Dumper printout
-of the variable or expression.  If no argument is passed it will
-dump the entire contents of the current variable stash (with
-private keys removed.
+DUMP inserts a Data::Dumper printout of the variable or expression.
+If no argument is passed it will dump the entire contents of the
+current variable stash (with private keys removed).
 
-If the template is being processed in a web request, DUMP will html
-encode the DUMP automatically.
+The output also includes the current file and line number that the
+DUMP directive was called from.
+
+See the DUMP configuration item for ways to customize and control
+the output available to the DUMP directive.
 
     [% DUMP %] # dumps everything
 
@@ -992,7 +1453,8 @@ TODO - enumerate the at least 7 ways to pass and use filters.
 Alias for the FILTER directive.  Note that | is similar to the
 '.' in CGI::Ex::Template.  Therefore a pipe cannot be used directly after a
 variable name in some situations (the pipe will act only on that variable).
-This is the behavior employed by TT3.
+This is the behavior employed by TT3.  To get the TT2 behavior for a PIPE, use
+the V2PIPE configuration item.
 
 =item C<FINAL>
 
@@ -1319,13 +1781,33 @@ two tags themselves must be supplied.
 
 The named tags are (duplicated from TT):
 
-    template => ['[%',   '%]'],  # default
-    metatext => ['%%',   '%%'],  # Text::MetaText
-    star     => ['[*',   '*]'],  # TT alternate
-    php      => ['<?',   '?>'],  # PHP
-    asp      => ['<%',   '%>'],  # ASP
-    mason    => ['<%',   '>' ],  # HTML::Mason
-    html     => ['<!--', '-->'], # HTML comments
+    asp       => ['<%',     '%>'    ], # ASP
+    default   => ['\[%',    '%\]'   ], # default
+    html      => ['<!--',   '-->'   ], # HTML comments
+    mason     => ['<%',     '>'     ], # HTML::Mason
+    metatext  => ['%%',     '%%'    ], # Text::MetaText
+    php       => ['<\?',    '\?>'   ], # PHP
+    star      => ['\[\*',   '\*\]'  ], # TT alternate
+    template  => ['\[%',    '%\]'   ], # Normal Template Toolkit
+    template1 => ['[\[%]%', '%[%\]]'], # allow TT1 style
+    tt2       => ['\[%',    '%\]'   ], # TT2
+
+If custom tags are supplied, by default they are escaped using
+quotemeta.  You may also pass explicitly quoted strings,
+or regular expressions as arguments as well (if your
+regex begins with a ', ", or / you must quote it.
+
+    [% TAGS [<] [>] %]          matches "[<] tag [>]"
+
+    [% TAGS '[<]' '[>]' %]      matches "[<] tag [>]"
+
+    [% TAGS "[<]" "[>]" %]      matches "[<] tag [>]"
+
+    [% TAGS /[<]/ /[>]/ %]      matches "< tag >"
+
+    [% TAGS ** ** %]            matches "** tag **"
+
+    [% TAGS /**/ /**/ %]        Throws an exception.
 
 =item C<THROW>
 
@@ -1493,16 +1975,24 @@ file).
 
     # The LOAD_PERL directive should be set to 1
     [% USE cet = CGI::Ex::Template %]
-    [%~ cet.dump_parse('2 * 3').replace('\s+', ' ') %]
+    [%~ cet.dump_parse_expr('2 * 3').replace('\s+', ' ') %]
 
 Would print:
 
-    $VAR1 = [ \[ '*', '2', '3' ], 0 ];
+    $VAR1 = [ [ undef, '*', '2', '3' ], 0 ];
 
 See the PLUGIN_BASE, and PLUGINS configuration items.
 
 See the documentation for Template::Manual::Plugins.
 
+=item C<VIEW>
+
+Implement a TT style view.  For more information, please
+see the Template::View documentation.  This DIRECTIVE
+will correctly parse the arguments and then pass them
+along to a newly created Template::View object.  It
+will fail if Template::View can not be found.
+
 =item C<WHILE>
 
 Will process a block of code while a condition is true.
@@ -1587,7 +2077,7 @@ tighter it binds).
 
 =item C<.>
 
-Binary.  The dot operator.  Allows for accessing sub-members, methods, or
+The dot operator.  Allows for accessing sub-members, methods, or
 virtual methods of nested data structures.
 
     my $obj->process(\$content, {a => {b => [0, {c => [34, 57]}]}}, \$output);
@@ -1605,7 +2095,7 @@ call the vmethod - use "|".
 
 =item C<|>
 
-Binary.  The pipe operator.  Similar to the dot operator.  Allows for
+The pipe operator.  Similar to the dot operator.  Allows for
 explicit calling of virtual methods and filters (filters are "merged"
 with virtual methods in CGI::Ex::Template and TT3) when accessing
 hashrefs and objects.  See the note for the "." operator.
@@ -1648,31 +2138,57 @@ A simple fix is to do any of the following:
 This shouldn't be too much hardship and offers the great return of disambiguating
 virtual method access.
 
+=item C<\>
+
+Unary.  The reference operator.  Not well publicized in TT.  Stores a reference
+to a variable for use later.  Can also be used to "alias" long names.
+
+    [% f = 7 ; foo = \f ; f = 8 ; foo %] => 8
+
+    [% foo = \f.g.h.i.j.k; f.g.h.i.j.k = 7; foo %] => 7
+
+    [% f = "abcd"; foo = \f.replace("ab", "-AB-") ; foo %] => -AB-cd
+
+    [% f = "abcd"; foo = \f.replace("bc") ; foo("-BC-") %] => a-BC-d
+
+    [% f = "abcd"; foo = \f.replace ; foo("cd", "-CD-") %] => ab-CD-
+
+=item C<++ -->
+
+Pre and post increment and decrement.  My be used as either a prefix
+or postfix operator.
+
+    [% ++a %][% ++a %] => 12
+
+    [% a++ %][% a++ %] => 01
+
+    [% --a %][% --a %] => -1-2
+
+    [% a-- %][% a-- %] => 0-1
+
 =item C<**  ^  pow>
 
-Binary.  X raised to the Y power.  This isn't available in TT 2.15.
+Right associative binary.  X raised to the Y power.  This isn't available in TT 2.15.
 
     [% 2 ** 3 %] => 8
 
 =item C<!>
 
-Unary not.  Negation of the value.
+Prefix not.  Negation of the value.
 
-=item C<-  unary_minus>
+=item C<->
 
-Unary minus.  Returns the value multiplied by -1.  The operator
-"unary_minus" is used internally by CGI::Ex::Template to provide for -
-to be listed in the precedence table twice.
+Prefix minus.  Returns the value multiplied by -1.
 
     [% a = 1 ; b = -a ; b %] => -1
 
 =item C<*>
 
-Binary. Multiplication.
+Left associative binary. Multiplication.
 
 =item C</  div  DIV>
 
-Binary. Division.  Note that / is floating point division, but div and
+Left associative binary. Division.  Note that / is floating point division, but div and
 DIV are integer division.
 
    [% 10  /  4 %] => 2.5
@@ -1680,58 +2196,63 @@ DIV are integer division.
 
 =item C<%  mod  MOD>
 
-Binary. Modulus.
+Left associative binary. Modulus.
 
    [% 15 % 8 %] => 7
 
 =item C<+>
 
-Binary.  Addition.
+Left associative binary.  Addition.
 
 =item C<->
 
-Binary.  Minus.
+Left associative binary.  Minus.
 
 =item C<_  ~>
 
-Binary.  String concatenation.
+Left associative binary.  String concatenation.
 
     [% "a" ~ "b" %] => ab
 
 =item C<< <  >  <=  >= >>
 
-Binary.  Numerical comparators.
+Non associative binary.  Numerical comparators.
 
 =item C<lt  gt  le  ge>
 
-Binary.  String comparators.
+Non associative binary.  String comparators.
 
 =item C<==  eq>
 
-Binary.  Equality test.  TT chose to use Perl's eq for both operators.
+Non associative binary.  Equality test.  TT chose to use Perl's eq for both operators.
 There is no test for numeric equality.
 
 =item C<!= ne>
 
-Binary.  Non-equality test.  TT chose to use Perl's ne for both
+Non associative binary.  Non-equality test.  TT chose to use Perl's ne for both
 operators.  There is no test for numeric non-equality.
 
 =item C<&&>
 
-Multiple arity.  And.  All values must be true.  If all values are true, the last
+Left associative binary.  And.  All values must be true.  If all values are true, the last
 value is returned as the truth value.
 
     [% 2 && 3 && 4 %] => 4
 
 =item C<||>
 
-Multiple arity.  Or.  The first true value is returned.
+Right associative binary.  Or.  The first true value is returned.
 
     [% 0 || '' || 7 %] => 7
 
+Note: perl is left associative on this operator - but it doesn't matter because
+|| has its own precedence level.  Setting it to right allows for CET to short
+circuit earlier in the expression optree (left is (((1,2), 3), 4) while right
+is (1, (2, (3, 4))).
+
 =item C<..>
 
-Binary.  Range creator.  Returns an arrayref containing the values
+Non associative binary.  Range creator.  Returns an arrayref containing the values
 between and including the first and last arguments.
 
     [% t = [1 .. 5] %] => variable t contains an array with 1,2,3,4, and 5
@@ -1744,43 +2265,60 @@ The .. operator is the only operator that returns a list of items.
 
 =item C<? :>
 
-Trinary.  Can be nested with other ?: pairs.
+Ternary - right associative.  Can be nested with other ?: pairs.
 
     [% 1 ? 2 : 3 %] => 2
     [% 0 ? 2 : 3 %] => 3
 
+=item C<*= += -= /= **= %= ~=>
+
+Self-modifying assignment - right associative.  Sets the left hand side
+to the operation of the left hand side and right (clear as mud).
+In order to not conflict with SET, FOREACH and other operations, this
+operator is only available in parenthesis.
+
+   [% a = 2 %][%  a += 3  %] --- [% a %]    => --- 5   # is handled by SET
+   [% a = 2 %][% (a += 3) %] --- [% a %]    => 5 --- 5
+
 =item C<=>
 
-Assignment.  Sets the left-hand side to the value of the righthand side.  In order
+Assignment - right associative.  Sets the left-hand side to the value of the righthand side.  In order
 to not conflict with SET, FOREACH and other operations, this operator is only
 available in parenthesis.  Returns the value of the righthand side.
 
-   [% (a = 1) %] --- [% a %] => 1 --- 1
+   [%  a = 1  %] --- [% a %]    => --- 1   # is handled by SET
+   [% (a = 1) %] --- [% a %]    => 1 --- 1
 
 =item C<not  NOT>
 
-Lower precedence version of the '!' operator.
+Prefix. Lower precedence version of the '!' operator.
 
 =item C<and  AND>
 
-Lower precedence version of the '&&' operator.
+Left associative. Lower precedence version of the '&&' operator.
 
 =item C<or OR>
 
-Lower precedence version of the '||' operator.
+Right associative. Lower precedence version of the '||' operator.
 
-=item C<hash>
+=item C<{}>
 
-Multiple arity.  This operator is not used in TT.  It is used internally
+This operator is not used in TT.  It is used internally
 by CGI::Ex::Template to delay the creation of a hash until the
 execution of the compiled template.
 
-=item C<array>
+=item C<[]>
 
-Multiple arity.  This operator is not used in TT.  It is used internally
+This operator is not used in TT.  It is used internally
 by CGI::Ex::Template to delay the creation of an array until the
 execution of the compiled template.
 
+=item C<qr>
+
+This operator is not used in TT.  It is used internally
+by CGI::Ex::Template to store a regular expression and its options.
+It will return a compiled Regexp object when compiled.
+
 =back
 
 
@@ -1843,7 +2381,7 @@ Collapse adjacent whitespace to a single space.  The "=" is used to indicate CHO
 
     Hello.
 
-    [%- "Hi." -%]
+    [%= "Hi." =%]
 
     Howdy.
 
@@ -1857,7 +2395,7 @@ Remove all adjacent whitespace.  The "~" is used to indicate CHOMP_GREEDY.
 
     Hello.
 
-    [%- "Hi." -%]
+    [%~ "Hi." ~%]
 
     Howdy.
 
@@ -1873,13 +2411,13 @@ the TT config documentation.
 
 These variables should be passed to the "new" constructor.
 
-   my $obj = CGI::Ex::Template->new(
-       VARIABLES  => \%hash_of_variables,
-       AUTO_RESET => 0,
-       TRIM       => 1,
-       POST_CHOMP => "=",
-       PRE_CHOMP  => "-",
-   );
+    my $obj = CGI::Ex::Template->new(
+        VARIABLES  => \%hash_of_variables,
+        AUTO_RESET => 0,
+        TRIM       => 1,
+        POST_CHOMP => "=",
+        PRE_CHOMP  => "-",
+    );
 
 
 =over 4
@@ -1888,6 +2426,12 @@ These variables should be passed to the "new" constructor.
 
 Boolean.  Default false.  Are absolute paths allowed for included files.
 
+=item ANYCASE
+
+Allow directive matching to be case insensitive.
+
+    [% get 23 %] prints 23 with ANYCASE => 1
+
 =item AUTO_RESET
 
 Boolean.  Default 1.  Clear blocks that were set during the process method.
@@ -1896,10 +2440,10 @@ Boolean.  Default 1.  Clear blocks that were set during the process method.
 
 A hashref of blocks that can be used by the process method.
 
-   BLOCKS => {
-       block_1 => sub { ... }, # coderef that returns a block
-       block_2 => 'A String',  # simple string
-   },
+    BLOCKS => {
+        block_1 => sub { ... }, # coderef that returns a block
+        block_2 => 'A String',  # simple string
+    },
 
 Note that a Template::Document cannot be supplied as a value (TT
 supports this).  However, it is possible to supply a value that is
@@ -1936,49 +2480,7 @@ compiled template.  Variables defined here cannot be overridden.
     Will have the value 42 compiled in.
 
 Constants defined in this way can be chained as in [%
-constant.foo.bar.baz %] but may only interpolate values that are set
-before the compile process begins.  This goes one step beyond TT in
-that any variable set in VARIABLES, or PRE_DEFINE, or passed to the
-process method are allowed - they are not in TT.  Variables defined in
-the template are not available during the compile process.
-
-    GOOD:
-
-    CONSTANTS => {
-        foo  => {
-            bar => {baz => 42},
-            bim => 57,
-        },
-        bing => 'baz',
-        bang => 'bim',
-    },
-    VARIABLES => {
-        bam  => 'bar',
-    },
-
-    In the template
-
-    [% constants.foo.${constants.bang} %]
-
-    Will correctly print 57.
-
-    GOOD (non-tt behavior)
-
-    [% constants.foo.$bam.${constants.bing} %]
-
-    CGI::Ex::Template will print 42 because the value of bam is
-    known at compile time.  TT would print '' because the value of $bam
-    is not yet defined in the TT engine.
-
-    BAD:
-
-    In the template:
-
-    [% bam = 'somethingelse' %]
-    [% constants.foo.$bam.${constants.bing} %]
-
-    Will still print 42 because the value of bam used comes from
-    variables defined before the template was compiled.  TT will still print ''.
+constant.foo.bar.baz %].
 
 =item CONSTANT_NAMESPACE
 
@@ -1987,9 +2489,9 @@ value is 'constants'.
 
 =item DEBUG
 
-    Takes a list of constants |'ed together which enables different
-    debugging modes.  Alternately the lowercase names may be used (multiple
-    values joined by a ",".
+Takes a list of constants |'ed together which enables different
+debugging modes.  Alternately the lowercase names may be used
+(multiple values joined by a ",").
 
     The only supported TT values are:
     DEBUG_UNDEF (2)    - debug when an undefined value is used.
@@ -2010,13 +2512,75 @@ directive.
 
 =item DEFAULT
 
-The name of a default template file to use if the passed on is not found.
+The name of a default template file to use if the passed one is not found.
 
 =item DELIMITER
 
 String to use to split INCLUDE_PATH with.  Default is :.  It is more
 straight forward to just send INCLUDE_PATH an arrayref of paths.
 
+=item DUMP
+
+Configures the behavior of the DUMP tag.  May be set to 0, a hashref,
+or another true value.  Default is true.
+
+If set to 0, all DUMP directives will do nothing.  This is useful if
+you would like to turn off the DUMP directives under some environments.
+
+IF set to a true value (or undefined) then DUMP directives will operate.
+
+If set to a hashref, the values of the hash can be used to configure
+the operation of the DUMP directives.  The following are the values
+that can be set in this hash.
+
+=over 4
+
+=item EntireStash
+
+Default 1.  If set to 0, then the DUMP directive will not print the
+entire contents of the stash when a DUMP directive is called without
+arguments.
+
+=item handler
+
+Defaults to an internal coderef.  If set to a coderef, the DUMP directive will pass the
+arguments to be dumped and expects a string with the dumped data.  This
+gives complete control over the dump process.
+
+Note 1: The default handler makes sure that values matching the
+private variable regex are not included.  If you install your own handler,
+you will need to take care of these variables if you intend for them
+to not be shown.
+
+Note 2: If you would like the name of the variable to be dumped, include
+the string '$VAR1' and the DUMP directive will interpolate the value.  For
+example, to dump all output as YAML - you could do the following:
+
+    DUMP => {
+       handler => sub {
+           require YAML;
+           return "\$VAR1 =\n".YAML::Dump(shift);
+       },
+    }
+
+=item header
+
+Default 1.  Controls whether a header is printed for each DUMP directive.
+The header contains the file and line number the DUMP directive was
+called from.  If set to 0 the headers are disabled.
+
+=item html
+
+Defaults to 1 if $ENV{'REQUEST_METHOD'} is set - 0 otherwise.  If set to
+1, then the output of the DUMP directive is passed to the html filter
+and encased in "pre" tags.  If set to 0 no html encoding takes place.
+
+=item Sortkeys, Useqq, Ident, Pad, etc
+
+Any of the Data::Dumper configuration items may be passed.
+
+=back
+
 =item END_TAG
 
 Set a string to use as the closing delimiter for TT.  Default is "%]".
@@ -2040,9 +2604,9 @@ Allow for passing in TT style filters.
 
     my $str = q{
         [% a = "Hello" %]
-        1([% a | filter1 %])
-        2([% a | filter2 %])
-        3([% a | filter3 %])
+        1 ([% a | filter1 %])
+        2 ([% a | filter2 %])
+        3 ([% a | filter3 %])
     };
 
     my $obj = CGI::Ex::Template->new(FILTERS => $filters);
@@ -2050,9 +2614,9 @@ Allow for passing in TT style filters.
 
 Would print:
 
-        (11111)
-        (22222)
-        (33333)
+        (11111)
+        (22222)
+        (33333)
 
 Filters passed in as an arrayref should contain a coderef and a value
 indicating if they are dynamic or static (true meaning dynamic).  The
@@ -2080,13 +2644,26 @@ with the appropriate values from the variable cache (if INTERPOLATE is on).
 
     [% IF 1 %]The variable $variable had a value ${var.value}[% END %]
 
-
 =item LOAD_PERL
 
 Indicates if the USE directive can fall back and try and load a perl module
 if the indicated module was not found in the PLUGIN_BASE path.  See the
 USE directive.
 
+=item MAX_EVAL_RECURSE (CET only)
+
+Will use $CGI::Ex::Template::MAX_EVAL_RECURSE if not present.  Default is 50.
+Prevents runaway on the following:
+
+    [% f = "[% f|eval %]" %][% f|eval %]
+
+=item MAX_MACRO_RECURSE (CET only)
+
+Will use $CGI::Ex::Template::MAX_MACRO_RECURSE if not present.  Default is 50.
+Prevents runaway on the following:
+
+    [% MACRO f BLOCK %][% f %][% END %][% f %]
+
 =item NAMESPACE
 
 No Template::Namespace::Constants support.  Hashref of hashrefs representing
@@ -2132,7 +2709,8 @@ See the USE directive for more information.
 
 Default value is Template::Plugin.  The base module namespace
 that template plugins will be looked for.  See the USE directive
-for more information.
+for more information.  May be either a single namespace, or an arrayref
+of namespaces.
 
 =item POST_CHOMP
 
@@ -2197,7 +2775,7 @@ been executed.
 =item UNDEFINED_ANY
 
 This is not a TT configuration option.  This option expects to be a code
-ref that will be called if a variable is undefined during a call to get_variable.
+ref that will be called if a variable is undefined during a call to play_expr.
 It is passed the variable identity array as a single argument.  This
 is most similar to the "undefined" method of Template::Stash.  It allows
 for the "auto-defining" of a variable for use in the template.  It is
@@ -2216,6 +2794,48 @@ rather than in embedded expressions (such as [% a || b || c %]).
 
 You can also sub class the module and override the undefined_get method.
 
+=item V1DOLLAR
+
+This allows for some compatibility with TT1 templates.  The only real
+behavior change is that [% $foo %] becomes the same as [% foo %].  The
+following is a basic table of changes invoked by using V1DOLLAR.
+
+   With V1DOLLAR        Equivalent Without V1DOLLAR (Normal default)
+   "[% foo %]"          "[% foo %]"
+   "[% $foo %]"         "[% foo %]"
+   "[% ${foo} %]"       "[% ${foo} %]"
+   "[% foo.$bar %]"     "[% foo.bar %]"
+   "[% ${foo.bar} %]"   "[% ${foo.bar} %]"
+   "[% ${foo.$bar} %]"  "[% ${foo.bar} %]"
+   "Text: $foo"         "Text: $foo"
+   "Text: ${foo}"       "Text: ${foo}"
+   "Text: ${$foo}"      "Text: ${foo}"
+
+=item V2PIPE
+
+Restores the behavior of the pipe operator to be compatible with TT2.
+
+With V2PIPE = 1
+
+    [%- BLOCK a %]b is [% b %]
+    [% END %]
+    [%- PROCESS a b => 237 | repeat(2) %]
+
+    # output of block "a" with b set to 237 is passed to the repeat(2) filter
+
+    b is 237
+    b is 237
+
+With V2PIPE = 0 (default)
+
+    [%- BLOCK a %]b is [% b %]
+    [% END %]
+    [% PROCESS a b => 237 | repeat(2) %]
+
+    # b set to 237 repeated twice, and b passed to block "a"
+
+    b is 237237
+
 =item VARIABLES
 
 A hashref of variables to initialize the template stash with.  These
@@ -2230,11 +2850,6 @@ See the section on VARIABLES for the types of information that can be passed in.
 
 =over 4
 
-=item ANYCASE
-
-This will not be supported.  You will have to use the full case directive names.
-(It was in the beta code but was removed prior to release).
-
 =item WRAPPER
 
 This will be supported - just not done yet.
@@ -2243,10 +2858,6 @@ This will be supported - just not done yet.
 
 This will be supported - just not done yet.
 
-=item V1DOLLAR
-
-This will not be supported.
-
 =item LOAD_TEMPLATES
 
 CGI::Ex::Template has its own mechanism for loading and storing
@@ -2274,7 +2885,7 @@ Template::Toolkit or the appropriate plugin module.
 CGI::Ex::Template uses its own mechanism for loading filters.  TT
 would use the Template::Filters object to load filters requested via the
 FILTER directive.  The functionality for doing this in CGI::Ex::Template
-is contained in the list_filters method and the get_variable method.
+is contained in the list_filters method and the play_expr method.
 
 Full support is offered for the FILTERS configuration item.
 
@@ -2317,15 +2928,16 @@ $DIRECTIVES hashref.
 
 =head1 VARIABLE PARSE TREE
 
-CGI::Ex::Template parses templates into an tree of operations.  Even
-variable access is parsed into a tree.  This is done in a manner
-somewhat similar to the way that TT operates except that nested
-variables such as foo.bar|baz contain the '.' or '|' in between each
-name level.  Operators are parsed and stored as part of the variable (it
-may be more appropriate to say we are parsing a term or an expression).
+CGI::Ex::Template parses templates into an tree of operations (an AST
+or abstract syntax tree).  Even variable access is parsed into a tree.
+This is done in a manner somewhat similar to the way that TT operates
+except that nested variables such as foo.bar|baz contain the '.' or
+'|' in between each name level.  Operators are parsed and stored as
+part of the variable (it may be more appropriate to say we are parsing
+a term or an expression).
 
 The following table shows a variable or expression and the corresponding parsed tree
-(this is what the parse_variable method would return).
+(this is what the parse_expr method would return).
 
     one                [ 'one',  0 ]
     one()              [ 'one',  [] ]
@@ -2336,28 +2948,29 @@ The following table shows a variable or expression and the corresponding parsed
     one.${two().three} [ 'one',  0, '.', ['two', [], '.', 'three', 0], 0]
     2.34               2.34
     "one"              "one"
-    "one"|length       [ \"one", 0, '|', 'length', 0 ]
-    "one $a two"       [ \ [ '~', 'one ', ['a', 0], ' two' ], 0 ]
-    [0, 1, 2]          [ \ [ 'array', 0, 1, 2 ], 0 ]
-    [0, 1, 2].size     [ \ [ 'array', 0, 1, 2 ], 0, '.', 'size', 0 ]
-    ['a', a, $a ]      [ \ [ 'array', 'a', ['a', 0], [['a', 0], 0] ], 0]
-    {a  => 'b'}        [ \ [ 'hash',  'a', 'b' ], 0 ]
-    {a  => 'b'}.size   [ \ [ 'hash',  'a', 'b' ], 0, '.', 'size', 0 ]
-    {$a => b}          [ \ [ 'hash',  ['a', 0], ['b', 0] ], 0 ]
-    1 + 2              [ \ [ '+', 1, 2 ], 0]
-    a + b              [ \ [ '+', ['a', 0], ['b', 0] ], 0 ]
-    a * (b + c)        [ \ [ '*', ['a', 0], [ \ ['+', ['b', 0], ['c', 0]], 0 ]], 0 ]
-    (a + b)            [ \ [ '+', ['a', 0], ['b', 0] ]], 0 ]
-    (a + b) * c        [ \ [ '*', [ \ [ '+', ['a', 0], ['b', 0] ], 0 ], ['c', 0] ], 0 ]
-    a ? b : c          [ \ [ '?', ['a', 0], ['b', 0], ['c', 0] ], 0 ]
-    a || b || c        [ \ [ '||', ['a', 0], [ \ [ '||', ['b', 0], ['c', 0] ], 0 ] ], 0 ]
-    ! a                [ \ [ '!', ['a', 0] ], 0 ]
+    1 + 2              [ [ undef, '+', 1, 2 ], 0]
+    a + b              [ [ undef, '+', ['a', 0], ['b', 0] ], 0 ]
+    "one"|length       [ [ undef, '~', "one" ], 0, '|', 'length', 0 ]
+    "one $a two"       [ [ undef, '~', 'one ', ['a', 0], ' two' ], 0 ]
+    [0, 1, 2]          [ [ undef, '[]', 0, 1, 2 ], 0 ]
+    [0, 1, 2].size     [ [ undef, '[]', 0, 1, 2 ], 0, '.', 'size', 0 ]
+    ['a', a, $a ]      [ [ undef, '[]', 'a', ['a', 0], [['a', 0], 0] ], 0]
+    {a  => 'b'}        [ [ undef, '{}', 'a', 'b' ], 0 ]
+    {a  => 'b'}.size   [ [ undef, '{}', 'a', 'b' ], 0, '.', 'size', 0 ]
+    {$a => b}          [ [ undef, '{}', ['a', 0], ['b', 0] ], 0 ]
+    a * (b + c)        [ [ undef, '*', ['a', 0], [ [undef, '+', ['b', 0], ['c', 0]], 0 ]], 0 ]
+    (a + b)            [ [ undef, '+', ['a', 0], ['b', 0] ]], 0 ]
+    (a + b) * c        [ [ undef, '*', [ [undef, '+', ['a', 0], ['b', 0] ], 0 ], ['c', 0] ], 0 ]
+    a ? b : c          [ [ undef, '?', ['a', 0], ['b', 0], ['c', 0] ], 0 ]
+    a || b || c        [ [ undef, '||', ['a', 0], [ [undef, '||', ['b', 0], ['c', 0] ], 0 ] ], 0 ]
+    ! a                [ [ undef, '!', ['a', 0] ], 0 ]
 
 Some notes on the parsing.
 
     Operators are parsed as part of the variable and become part of the variable tree.
 
-    Operators are stored in the variable tree using a reference to the arrayref - which
+    Operators are stored in the variable tree using an operator identity array which
+    contains undef as the first value, the operator, and the operator arguments.  This
     allows for quickly descending the parsed variable tree and determining that the next
     node is an operator.
 
@@ -2368,12 +2981,12 @@ Some notes on the parsing.
 
 The following perl can be typed at the command line to view the parsed variable tree:
 
-    perl -e 'use CGI::Ex::Template; print CGI::Ex::Template::dump_parse("foo.bar + 2")."\n"'
+    perl -e 'use CGI::Ex::Template; print CGI::Ex::Template::dump_parse_expr("foo.bar + 2")."\n"'
 
 Also the following can be included in a template to view the output in a template:
 
     [% USE cet = CGI::Ex::Template %]
-    [%~ cet.dump_parse('foo.bar + 2').replace('\s+', ' ') %]
+    [%~ cet.dump_parse_expr('foo.bar + 2').replace('\s+', ' ') %]
 
 
 =head1 SEMI PUBLIC METHODS
@@ -2385,7 +2998,13 @@ may be re-implemented by subclasses of CET.
 
 =item C<dump_parse>
 
-This method allows for returning a Data::Dumper dump of a parsed variable.  It is mainly used for testing.
+This method allows for returning a Data::Dumper dump of a parsed
+template.  It is mainly used for testing.
+
+=item C<dump_parse_expr>
+
+This method allows for returning a Data::Dumper dump of a parsed
+variable.  It is mainly used for testing.
 
 =item C<exception>
 
@@ -2396,11 +3015,13 @@ $CGI::Ex::Template::PACKAGE_EXCEPTION.
 
 Executes a parsed tree (returned from parse_tree)
 
-=item C<get_variable>
+=item C<play_expr>
 
-Turns a variable identity array into the parsed variable.  This
-method is also responsible for playing operators and running virtual methods
-and filters.  The method could more accurately be called play_expression.
+Play the parsed expression.  Turns a variable identity array into the
+parsed variable.  This method is also responsible for playing
+operators and running virtual methods and filters.  The variable
+identity array may also contain literal values, or operator identity
+arrays.
 
 =item C<include_filename>
 
@@ -2434,14 +3055,14 @@ hash that contains the parsed tree.
 Allow for the multitudinous ways that TT parses arguments.  This allows
 for positional as well as named arguments.  Named arguments can be separated with a "=" or "=>",
 and positional arguments should be separated by " " or ",".  This only returns an array
-of parsed variables.  Use vivify_args to translate to the actual values.
+of parsed variables.   To get the actual values, you must call play_expr on each value.
 
 =item C<parse_tree>
 
 Used by load_parsed_tree.  This is the main grammar engine of the program.  It
 uses method in the $DIRECTIVES hashref to parse different DIRECTIVE TYPES.
 
-=item C<parse_variable>
+=item C<parse_expr>
 
 Used to parse a variable, an expression, a literal string, or a number.  It
 returns a parsed variable tree.  Samples of parsed variables can be found in the VARIABLE PARSE TREE
@@ -2458,7 +3079,7 @@ Creates an exception object from the arguments and dies.
 
 =item C<undefined_any>
 
-Called during get_variable if a value is returned that is undefined.  This could
+Called during play_expr if a value is returned that is undefined.  This could
 be used to magically create variables on the fly.  This is similar to Template::Stash::undefined.
 It is suggested that undefined_get be used instead.  Default behavior returns undef.  You
 may also pass a coderef via the UNDEFINED_ANY configuration variable.  Also, you can try using
@@ -2470,11 +3091,6 @@ Called when a variable is undefined during a GET directive.  This is useful to
 see if a value that is about to get inserted into the text is undefined.  undefined_any is a little
 too general for most cases.  Also, you may pass a coderef via the UNDEFINED_GET configuration variable.
 
-=item C<vivify_args>
-
-Turns an arrayref of arg identities parsed by parse_args and turns
-them into the actual values.
-
 =back
 
 
@@ -2495,7 +3111,7 @@ upon operator precedence.
 Used to create a "pseudo" context object that allows for portability
 of TT plugins, filters, and perl blocks that need a context object.
 
-=ITEM C<DEBUG>
+=item C<DEBUG>
 
 TT2 Holdover that is used once for binmode setting during a TT2 test.
 
@@ -2505,7 +3121,7 @@ Used to get debug info on a directive if DEBUG_DIRS is set.
 
 =item C<filter_*>
 
-Methods by these names implement filters that are more than one line.
+Methods by these names implement filters that are more complex than one liners.
 
 =item C<get_line_number_by_index>
 
@@ -2525,7 +3141,11 @@ Methods by these names are used by execute_tree to execute the parsed tree.
 
 =item C<play_operator>
 
-Used to execute any found operators
+Used to execute any found operators.  The single argument is
+an operator identy returned by the parse_expr method (if the expression
+contained an operator).  Normally you would just call play_expr
+instead and it will call play_operator if the structure
+contains an operator.
 
 =item C<_process>
 
@@ -2546,12 +3166,7 @@ by the pseudo context object and may disappear at some point.
 
 =item C<vmethod_*>
 
-Methods by these names implement virtual methods that are more than one line.
-
-=item C<weak_copy>
-
-Used to create a weak reference to self to avoid circular references. (this
-is needed by macros)
+Methods by these names implement virtual methods that are more complex than oneliners.
 
 =back
 
@@ -2560,4 +3175,8 @@ is needed by macros)
 
 Paul Seamons <paul at seamons dot com>
 
+=head1 LICENSE
+
+This module may be distributed under the same terms as Perl itself.
+
 =cut
This page took 0.068943 seconds and 4 git commands to generate.