Skip to content

Commit

Permalink
[Doten] Handle transforms a bit more nicely
Browse files Browse the repository at this point in the history
  • Loading branch information
tene committed Jun 11, 2010
1 parent c076bf6 commit 3b07397
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Ratel.pm
Expand Up @@ -8,7 +8,8 @@ class Ratel {
# XXX Needs to be re-thought to allow wrapping the contents of the
# unquote, use parameterized delims, etc...
%!transforms = %transforms;
%!transforms{'[%='} = '[% print';
%!transforms{'='} = -> $a {"print $a"};
%!transforms{'!'} = -> $a {"print %attrs<$a>"};
$.source($source);
}
multi method load(Str $filename) {
Expand All @@ -23,7 +24,7 @@ class Ratel {
$!source = $text;
my $source = "%]$text[%";
for %!transforms.kv -> $k, $v {
$source.=subst($k, $v, :g);
$source.=subst((eval "/'[%$k' (.*?) '%]'/"), -> $match {'[%' ~ $v($match[0]) ~ '%]'}, :g);
}
@!hunks = $source.comb(/'%]' (.*?) '[%'/);
$!compiled
Expand Down

0 comments on commit 3b07397

Please sign in to comment.