Good day! We serve lots of WAP pages with HTML::Template. So this is my old WML patch updated for 2.9 in case anyone is interested. It's small, includes tests and docs so I still hope it will be included in base some day :)
-- Alex Kapranoff, $n=["1another7Perl213Just3hacker49"=~/\d|\D*/g]; $$n[0]={grep/\d/,@$n};print"@$n{1..4}\n"
--- Template.pm.orig Mon Jan 29 22:32:21 2007 +++ Template.pm Fri Mar 16 17:05:53 2007 @@ -138,6 +138,9 @@ need to be placed within a Javascript string. All \n, \r, ' and " characters are escaped. +Another escaping option is "ESCAPE=WML" which in addition to normal +"ESCAPE=HTML" transformations doubles all dollar signs as per WML specification. + You can assign a default value to a variable with the DEFAULT attribute. For example, this will output "the devil gave me a taco" if the "who" variable is not set. @@ -1817,6 +1820,7 @@ my $ESCAPE = HTML::Template::ESCAPE->new(); my $JSESCAPE = HTML::Template::JSESCAPE->new(); my $URLESCAPE = HTML::Template::URLESCAPE->new(); + my $WMLESCAPE = HTML::Template::WMLESCAPE->new(); # all the tags that need NAMEs: my %need_names = map { $_ => 1 } @@ -1891,6 +1895,7 @@ (?:["']?[Hh][Tt][Mm][Ll]["']?) | (?:["']?[Uu][Rr][Ll]["']?) | (?:["']?[Jj][Ss]["']?) | + (?:["']?[Ww][Mm][Ll]["']?) | (?:["']?[Nn][Oo][Nn][Ee]["']?) ) # $5 => ESCAPE on ) @@ -1956,6 +1961,7 @@ (?:["']?[Hh][Tt][Mm][Ll]["']?) | (?:["']?[Uu][Rr][Ll]["']?) | (?:["']?[Jj][Ss]["']?) | + (?:["']?[Ww][Mm][Ll]["']?) | (?:["']?[Nn][Oo][Nn][Ee]["']?) ) # $15 => ESCAPE on ) @@ -2045,6 +2051,8 @@ push(@pstack, $URLESCAPE); } elsif ($escape =~ /^["']?[Jj][Ss]["']?$/) { push(@pstack, $JSESCAPE); + } elsif ($escape =~ /^["']?[Ww][Mm][Ll]["']?$/) { + push(@pstack, $WMLESCAPE); } elsif ($escape =~ /^["']?0["']?$/) { # do nothing if escape=0 } elsif ($escape =~ /^["']?[Nn][Oo][Nn][Ee]["']?$/ ) { @@ -2773,6 +2781,7 @@ *line = \$parse_stack[++$x] if ref $line eq 'HTML::Template::ESCAPE' or ref $line eq 'HTML::Template::JSESCAPE' or + ref $line eq 'HTML::Template::WMLESCAPE' or ref $line eq 'HTML::Template::URLESCAPE'; # either output the default or go back @@ -2829,6 +2838,7 @@ s/\r/\\r/g; $result .= $_; } + next; } elsif ($type eq 'HTML::Template::URLESCAPE') { $x++; *line = \$parse_stack[$x]; @@ -2852,6 +2862,24 @@ s!([^a-zA-Z0-9_.\-])!$URLESCAPE_MAP{$1}!g; $result .= $_; } + next; + } elsif ($type eq 'HTML::Template::WMLESCAPE') { + *line = \$parse_stack[++$x]; + if (defined($$line)) { + $_ = $$line; + + # straight from the CGI.pm bible. + s/&/&/g; + s/\"/"/g; #" + s/>/>/g; + s/</</g; + s/'/'/g; #' + + s/\$/\$\$/g; # WML substitutes variables on dollar + + $result .= $_; + } + next; } else { confess("HTML::Template::output() : Unknown item in parse_stack : " . $type); } @@ -3114,6 +3142,14 @@ } package HTML::Template::URLESCAPE; +sub new { + my $unused; + my $self = \$unused; + bless($self, $_[0]); + return $self; +} + +package HTML::Template::WMLESCAPE; sub new { my $unused; my $self = \$unused;
patch-t::99-old-test-pl.t
Description: Troff document
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Html-template-users mailing list Html-template-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/html-template-users