[MKDoc-commit] [Petal] defang on-error output and note that
implementation is
bruno at mkdoc.demon.co.uk
bruno at mkdoc.demon.co.uk
Mon Dec 5 15:32:17 GMT 2005
Log Message:
-----------
[Petal] defang on-error output and note that implementation is incomplete
Modified Files:
--------------
Petal:
Changes
MANIFEST
Petal/lib:
Petal.pm
Petal/lib/Petal:
CodeGenerator.pm
Added Files:
-----------
Petal/t:
092_on-error.t
Petal/t/data:
eval2.xml
-------------- next part --------------
Index: MANIFEST
===================================================================
RCS file: /var/spool/cvs/Petal/MANIFEST,v
retrieving revision 1.51
retrieving revision 1.52
diff -LMANIFEST -LMANIFEST -u -r1.51 -r1.52
--- MANIFEST
+++ MANIFEST
@@ -96,6 +96,7 @@
t/089_utf-8.t
t/090_dollarone-again.t
t/091_attribute-newline.t
+t/092_on-error.t
t/benchmark.pl
t/data/access_obj_array.html
t/data/access_obj_hash.html
@@ -120,6 +121,7 @@
t/data/entities.xml
t/data/error_on_undef_var.html
t/data/eval.xml
+t/data/eval2.xml
t/data/gettext/html/index.html
t/data/gettext/html/menu-no-css.html
t/data/gettext/mo/en.mo
Index: Changes
===================================================================
RCS file: /var/spool/cvs/Petal/Changes,v
retrieving revision 1.141
retrieving revision 1.142
diff -LChanges -LChanges -u -r1.141 -r1.142
--- Changes
+++ Changes
@@ -4,6 +4,8 @@
- $Petal::CodeGenerator::PI_RE should be applied newline insensitively
- pod fixes
- Cookbook tal:repeat example (DSL)
+ - pod note that on-error isn't fully implemented
+ - defang html metacharacters in on-error output
2.17 Wed Sep 7 15:30:00 2005
- test 041 check that becomes chr(160) not chr(194) (William McKee)
Index: CodeGenerator.pm
===================================================================
RCS file: /var/spool/cvs/Petal/lib/Petal/CodeGenerator.pm,v
retrieving revision 1.47
retrieving revision 1.48
diff -Llib/Petal/CodeGenerator.pm -Llib/Petal/CodeGenerator.pm -u -r1.47 -r1.48
--- lib/Petal/CodeGenerator.pm
+++ lib/Petal/CodeGenerator.pm
@@ -381,6 +381,11 @@
$class->add_code("if (defined \$\@ and \$\@) {");
$class->indent_increment();
+
+ $variable =~ s/\&/&/g;
+ $variable =~ s/\</</g;
+ $variable =~ s/\>/>/g;
+ $variable =~ s/\"/"/g;
$variable = quotemeta ($variable);
$class->add_code($class->_add_res("\"$variable\";"));
$class->indent_decrement();
--- /dev/null
+++ t/092_on-error.t
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use lib ('lib');
+use Test::More 'no_plan';
+use Petal;
+
+$|=1;
+
+$Petal::BASE_DIR = './t/data/';
+$Petal::DISK_CACHE = 0;
+$Petal::MEMORY_CACHE = 0;
+$Petal::TAINT = 1;
+
+my $template_file = 'eval2.xml';
+my $template = new Petal ($template_file);
+my $string = $template->process;
+
+TODO: {
+ local $TODO = 'http://www.zope.org/Wikis/DevSite/Projects/ZPT/TAL%20Specification%201.4/#on-error';
+ like ($string, qr/<span>booo<\/span>/, 'booo (XML out)');
+};
+
+unlike ($string, qr/<</, 'invalid XML');
+like ($string, qr/<</, 'valid XML');
+
+__END__
Index: Petal.pm
===================================================================
RCS file: /var/spool/cvs/Petal/lib/Petal.pm,v
retrieving revision 1.137
retrieving revision 1.138
diff -Llib/Petal.pm -Llib/Petal.pm -u -r1.137 -r1.138
--- lib/Petal.pm
+++ lib/Petal.pm
@@ -1195,6 +1195,10 @@
=head2 on-error
+Warning: this is currently only partially implemented. C<on-error> may be used
+in Petal templates, but the expression isn't evaluated - Petal simply prints
+the expression as a string.
+
Abstract
<tag on-error="EXPRESSION">...</tag>
--- /dev/null
+++ t/data/eval2.xml
@@ -0,0 +1,2 @@
+<span petal:on-error="string:booo">$this/aint/gonna/work</span>
+<span petal:on-error="<<">$this/aint/gonna/work</span>
More information about the MKDoc-commit
mailing list