WML escaping for ::JIT
Alex Kapranoff <[email protected]> Fri, 16 Mar 2007 17:38:12 +0300
| Newsgroups | gmane.comp.lang.perl.modules.html-template |
|---|---|
| Organization | Inner Mongolia |
| Message-ID | <[email protected]> |
Patch to enable "ESCAPE=WML" in HTML::Template::JIT.
--
Alex Kapranoff,
$n=["1another7Perl213Just3hacker49"=~/\d|\D*/g];
$$n[0]={grep/\d/,@$n};print"@$n{1..4}\n"
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/html-template-users
patch-t::10escape.t
(application/x-troff, 973 B) - not displayed
patch-t::templates::wmlescape.tmpl
(text/plain, 187 B)
--- t/templates/wmlescape.tmpl.orig Thu Sep 16 15:55:22 2004 +++ t/templates/wmlescape.tmpl Thu Sep 16 15:55:43 2004 @@ -0,0 +1,2 @@ +Some WML escaped stuff: +<TMPL_VAR ESCAPE=WML STUFF>
patch-z-Compiler.pm
(text/x-perl, 1.1 KB)
--- JIT/Compiler.pm.orig Tue Jan 17 15:55:30 2006
+++ JIT/Compiler.pm Tue Jan 17 15:56:41 2006
@@ -266,6 +266,8 @@
$do_escape = 'URL';
} elsif ($type eq 'HTML::Template::JSESCAPE') {
$do_escape = 'JS';
+ } elsif ($type eq 'HTML::Template::WMLESCAPE') {
+ $do_escape = 'WML';
} elsif ($type eq 'HTML::Template::NOOP') {
# noop
} else {
@@ -525,6 +527,35 @@
}
END
+ } elsif ($escape eq 'WML') {
+ push @code, <<END;
+ switch (c) {
+ case '&':
+ sv_insert(temp_sv, len, 1, "&", 5);
+ len += 4;
+ break;
+ case '"':
+ sv_insert(temp_sv, len, 1, """, 6);
+ len += 5;
+ break;
+ case '>':
+ sv_insert(temp_sv, len, 1, ">", 4);
+ len += 3;
+ break;
+ case '<':
+ sv_insert(temp_sv, len, 1, "<", 4);
+ len += 3;
+ break;
+ case '\\'':
+ sv_insert(temp_sv, len, 1, "'", 5);
+ len += 4;
+ break;
+ case '\$':
+ sv_insert(temp_sv, len, 1, "\$\$", 2);
+ len++;
+ }
+END
+
} else {
die "Unknown escape type '$escape'.";
}