X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-CGI-Ex;a=blobdiff_plain;f=lib%2FCGI%2FEx%2FTemplate.pod;h=cbfde4bf42631b29f076f77dae9b55cd6d0ccc13;hp=cd7dd094f9366e6d0410f6658e8cf051801b92e4;hb=83f0c6a9aaf9bc520cef93b958d51a5d85e8999c;hpb=d2b7c937e86e6e8c4b4193e9f4a8da075919b4fd diff --git a/lib/CGI/Ex/Template.pod b/lib/CGI/Ex/Template.pod index cd7dd09..cbfde4b 100644 --- a/lib/CGI/Ex/Template.pod +++ b/lib/CGI/Ex/Template.pod @@ -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. @@ -2195,7 +2193,7 @@ Collapse adjacent whitespace to a single space. The "=" is used to indicate CHO Hello. - [%- "Hi." -%] + [%= "Hi." =%] Howdy. @@ -2209,7 +2207,7 @@ Remove all adjacent whitespace. The "~" is used to indicate CHOMP_GREEDY. Hello. - [%- "Hi." -%] + [%~ "Hi." ~%] Howdy. @@ -2350,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); @@ -2360,9 +2358,9 @@ Allow for passing in TT style filters. Would print: - (11111) - (22222) - (33333) + 1 (11111) + 2 (22222) + 3 (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 @@ -2853,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 - -Used to create a weak reference to self to avoid circular references. (this -is needed by macros) - =back