CC: | alan [...] pair.com |
Subject: | Recent filter feature breaks expresions that use logical or: '||' |
The recent addition to Text::MicroMason, which permits filters to be
added to the end of <% %> blocks, has caused expressions inside
templates such as this to break:
<% $foo || 0 %>
The problem is that MicroMason is seeing the '| 0' at the end of the
string and ignoring its context.
I have attached a diff to the 33-filters.t test file, which demonstrates
this failure condition.
Also attached is a diff for Text::MicroMason::Filters, which I believe
corrects this bug.
Subject: | 33-filters.t.diff |
14a15,23
> # Test an expression inside a template using logical or.
>
> {
> my $src = q(Var is <% $ARGS{foo} || 0 %>);
>
> $m->execute( text => $src );
> }
>
> ######################################################################
Subject: | Filters.pm.diff |
34c34
< my $filt_flags = ($token =~ s/\|\s*(\w+(?:[\s\,]+\w+)*)\s*\z//) ? $1 : '';
---
> my $filt_flags = ($token =~ s/[^\|]\|\s*(\w+(?:[\s\,]+\w+)*)\s*\z//) ? $1 : '';