Hello,
Attached is a patch against release 2.06 for the "text contains OUT" bug.
The patch also includes a new test in 09-regression.t that exercises the error.
-Simon
---
diff -r -u Text-MicroMason-2.06/MicroMason/Base.pm Text-MicroMason-2.06-assembly-patch/MicroMason/B
+ase.pm
--- Text-MicroMason-2.06/MicroMason/Base.pm 2009-11-11 11:24:24.000000000 -0500
+++ Text-MicroMason-2.06-assembly-patch/MicroMason/Base.pm 2009-11-14 18:09:29.000000000 -0500
@@ -263,7 +263,6 @@
my ( $order, $fragments, $token_map ) = $self->assembler_vars();
my %token_streams = map { $_ => [] } map { ( /^\W?\@(\w+)$/ ) } @$order;
- my ($output) = $fragments->{add_output};
while ( scalar @tokens ) {
my ( $type, $token ) = splice( @tokens, 0, 2 );
@@ -274,11 +273,18 @@
or $self->croak_msg( "Unexpected token type '$type': '$token'" );
($type, $token) = &$sub( $self, $token );
}
-
+
if ( my $typedef = $token_map->{ $type } ) {
- $typedef =~ s{\bTOKEN\b}{$token}g;
- $typedef =~ s{\bQUOTED\b}{qq(\Q$token\E)}g;
- $typedef =~ s{\bOUT\b}{$output}g;
+ # Perform token map substitution in a single pass so that uses of
+ # OUT in the token text are not improperly converted to output calls.
+ # -- Simon, 2009-11-14
+ my %substitution_map = (
+ 'OUT' => $fragments->{add_output},
+ 'TOKEN' => $token,
+ 'QUOTED' => "qq(\Q$token\E)",
+ );
+ $typedef =~ s/\b(OUT|TOKEN|QUOTED)\b/$substitution_map{$1}/g;
+
( $type, $token ) = split ' ', $typedef, 2;
}
diff -r -u Text-MicroMason-2.06/t/09-regression.t Text-MicroMason-2.06-assembly-patch/t/09-regressi
+on.t
--- Text-MicroMason-2.06/t/09-regression.t 2009-10-30 16:03:16.000000000 -0400
+++ Text-MicroMason-2.06-assembly-patch/t/09-regression.t 2009-11-14 18:02:04.000000000 -0500
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 24;
+use Test::More tests => 25;
use_ok 'Text::MicroMason';
@@ -177,3 +177,11 @@
}
######################################################################
+
+TEXT_CONTAINS_OUT: {
+ my $scr_inout = 'IN <% "and" %> OUT burger';
+ my $res_inout = 'IN and OUT burger';
+ is $m->execute( text => $scr_inout), $res_inout;
+}
+
+######################################################################