Author: spadkins
Date: Thu Aug 31 09:39:39 2006
New Revision: 6829
Modified:
p5ee/trunk/App-Widget/lib/App/TemplateEngine.pm
Log:
do the {xyz} subs before the [%xyz%] subs. strict disallows {xyz} syntax
Modified: p5ee/trunk/App-Widget/lib/App/TemplateEngine.pm
==============================================================================
--- p5ee/trunk/App-Widget/lib/App/TemplateEngine.pm (original)
+++ p5ee/trunk/App-Widget/lib/App/TemplateEngine.pm Thu Aug 31 09:39:39 2006
@@ -281,28 +281,31 @@
$values = {} if (! defined $values);
my $options = $context->{options};
- while ( $template_text =~ /\[%(\+?)([^%]+)%\]/ ) { # vars of the form
[%var%] or [%+var%]
- $expand = $1;
- $var = $2;
- if ($expand) {
- eval {
- $value = $context->widget($var)->html();
- };
- $value = "[$var: [EMAIL PROTECTED]" if ($@);
- }
- elsif (defined $values->{$var}) {
- $value = $values->{$var};
- }
- elsif (defined $options->{$var}) {
- $value = $options->{$var};
- }
- else {
- $value = "";
+ # strict syntax usage is [%var%] rather than {var} which can get you in
trouble
+ if (! $self->{strict}) {
+ while ( $template_text =~ /\{(\+?)([a-zA-Z][a-zA-Z0-9_.-]*)\}/ ) { #
vars of the form {var} or {+var}
+ $expand = $1;
+ $var = $2;
+ if ($expand) {
+ eval {
+ $value = $context->widget($var)->html();
+ };
+ $value = "[$var: [EMAIL PROTECTED]" if ($@);
+ }
+ elsif (defined $values->{$var}) {
+ $value = $values->{$var};
+ }
+ elsif (defined $options->{$var}) {
+ $value = $options->{$var};
+ }
+ else {
+ $value = "";
+ }
+ $template_text =~ s/\{$var\}/$value/g;
}
- $template_text =~ s/\[%\+$var%\]/$value/g;
}
- while ( $template_text =~ /\{(\+?)([a-zA-Z][a-zA-Z0-9_.-]*)\}/ ) { # vars
of the form {var} or {+var}
+ while ( $template_text =~ /\[%(\+?)([^%]+)%\]/ ) { # vars of the form
[%var%] or [%+var%]
$expand = $1;
$var = $2;
if ($expand) {
@@ -320,7 +323,7 @@
else {
$value = "";
}
- $template_text =~ s/\{$var\}/$value/g;
+ $template_text =~ s/\[%\+$var%\]/$value/g;
}
&App::sub_exit($template_text) if ($App::trace);