]> Dogcows Code - chaz/p5-CGI-Ex/blobdiff - lib/CGI/Ex/Template.pod
CGI::Ex 2.06
[chaz/p5-CGI-Ex] / lib / CGI / Ex / Template.pod
index d954eabb68e58003f59ea9c8cec7768fbc88e37f..cbfde4bf42631b29f076f77dae9b55cd6d0ccc13 100644 (file)
@@ -272,11 +272,11 @@ to virtual methods.
        | Hash.keys
        | List.join(", ") %] # = a, b
 
-=item Added "as" scalar, list, and hash virtual methods.
+=item Added "fmt" scalar, list, and hash virtual methods.
 
-    [% list.as("%s", ", ") %]
+    [% list.fmt("%s", ", ") %]
 
-    [% hash.as("%s => %s", "\n") %]
+    [% hash.fmt("%s => %s", "\n") %]
 
 =item Whitespace is less meaningful. (TT3)
 
@@ -306,13 +306,13 @@ to virtual methods.
 
     [% a = 1.2e-20 %]
 
-    [% 123.as('%.3e') %] # = 1.230e+02
+    [% 123.fmt('%.3e') %] # = 1.230e+02
 
 =item Allow for hexidecimal input. (TT3)
 
     [% a = 0xff0000 %][% a %] # = 16711680
 
-    [% a = 0xff2 / 0xd; a.as('%x') %] # = 13a
+    [% a = 0xff2 / 0xd; a.fmt('%x') %] # = 13a
 
 =item FOREACH variables can be nested.
 
@@ -399,13 +399,8 @@ CET has its own built in recursive grammar system.
 
 =item There are no references.
 
-There was in initial beta tests, but it was decided to remove the little used feature.
-
-It makes it the same as
-
-    [% obj.method("foo") %]
-
-This is removed in CET.
+There were in initial beta tests, but it was decided to remove the little used feature which
+took a length of code to implement.
 
 =item The DEBUG directive is more limited.
 
@@ -416,7 +411,8 @@ are on rather than a general line range.
 
 =item There is no ANYCASE configuration item.
 
-There was in initial beta tests, but it was dropped in favor of consistent parsing syntax.
+There was in initial beta tests, but it was dropped in favor of consistent parsing syntax (and
+a minimal amount of speedup).
 
 =item There is no V1DOLLAR configuration item.
 
@@ -632,13 +628,13 @@ Scientific notation is supported.
 
     [% 314159e-5 + 0 %]      Prints 3.14159.
 
-    [% .0000001.as('%.1e') %]  Prints 1.0e-07
+    [% .0000001.fmt('%.1e') %]  Prints 1.0e-07
 
 Hexidecimal input is also supported.
 
     [% 0xff + 0 %]    Prints 255
 
-    [% 48875.as('%x') %]  Prints beeb
+    [% 48875.fmt('%x') %]  Prints beeb
 
 =item Single quoted strings.
 
@@ -751,13 +747,8 @@ object (except for true filters such as eval and redirect).
 
 =item '0'
 
-    [% item = 'foo' %][% item.0 %] Returns self.  Allows for scalars to mask as arrays.
-
-=item as
-
-    [% item.as('%d') %]
-
-Similar to format.  Returns a string formatted with the passed pattern.  Default pattern is %s.
+    [% item = 'foo' %][% item.0 %] Returns self.  Allows for scalars to mask as arrays (scalars
+                                   already will, but this allows for more direct access).
 
 =item chunk
 
@@ -795,9 +786,16 @@ This is a filter and is not available via the Text virtual object.
 
     Same as the redirect filter.
 
+=item fmt
+
+    [% item.fmt('%d') %]
+
+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
+    [% item.format('%d') %] Print the string out in the specified format.  It is similar to
+    the "as" virtual method, except that the item is split on newline and each line is
     processed separately.
 
 =item hash
@@ -847,7 +845,7 @@ 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
 
@@ -868,13 +866,13 @@ This is a filter and is not available via the Text virtual object.
 
     [% item.replace("\s+", " ") %] Globally replace all space with  
 
-    [% item.replace("foo", "bar", 0) Replace only 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.
 
 =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.
 
 =item size
 
@@ -927,9 +925,9 @@ Virtual Object.
 
 =over 4
 
-=item as
+=item fmt
 
-    [% mylist.as('%s', ', ') %]
+    [% mylist.fmt('%s', ', ') %]
 
 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.
@@ -1035,9 +1033,9 @@ Virtual Object.
 
 =over 4
 
-=item as
+=item fmt
 
-    [% myhash.as('%s => %s', "\n") %]
+    [% myhash.fmt('%s => %s', "\n") %]
 
 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.
@@ -1912,7 +1910,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);
@@ -1930,7 +1928,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.
@@ -1988,13 +1986,13 @@ or postfix operator.
 
 =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<->
 
@@ -2004,11 +2002,11 @@ Prefix minus.  Returns the value multiplied by -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
@@ -2016,58 +2014,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
@@ -2080,14 +2083,14 @@ The .. operator is the only operator that returns a list of items.
 
 =item C<? :>
 
-Ternary.  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.  Sets the left hand side
+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.
@@ -2097,7 +2100,7 @@ operator is only available in parenthesis.
 
 =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.
 
@@ -2106,25 +2109,25 @@ available in parenthesis.  Returns the value of the righthand side.
 
 =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>
 
-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>
 
-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.
 
@@ -2190,7 +2193,7 @@ Collapse adjacent whitespace to a single space.  The "=" is used to indicate CHO
 
     Hello.
 
-    [%- "Hi." -%]
+    [%= "Hi." =%]
 
     Howdy.
 
@@ -2204,7 +2207,7 @@ Remove all adjacent whitespace.  The "~" is used to indicate CHOMP_GREEDY.
 
     Hello.
 
-    [%- "Hi." -%]
+    [%~ "Hi." ~%]
 
     Howdy.
 
@@ -2345,9 +2348,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);
@@ -2355,9 +2358,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
@@ -2502,7 +2505,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
@@ -2579,7 +2582,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.
 
@@ -2630,7 +2633,7 @@ 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',  [] ]
@@ -2701,7 +2704,7 @@ $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
@@ -2739,14 +2742,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.   To get the actual values, you must call get_variable on each value.
+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
@@ -2763,7 +2766,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
@@ -2848,11 +2851,6 @@ by the pseudo context object and may disappear at some point.
 
 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)
-
 =back
 
 
This page took 0.033176 seconds and 4 git commands to generate.