Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rework Ratel rendering

  • Loading branch information...
commit 4d4c5ed3b57be07716f7b95e1134ce538bccecf9 1 parent c9f4282
@tene tene authored
Showing with 16 additions and 4 deletions.
  1. +16 −4 lib/Ratel.pm
View
20 lib/Ratel.pm
@@ -17,17 +17,29 @@ class Ratel {
= $source.subst(/(['%]' | ^ ] .*? [ $ | '[%' ])/,
{";\$.emit-hunk({$index++});"},
:g);
- $!compiled = 'my sub print(*@args) { $*result ~= $_ for @args };'
- ~ $!compiled;
+ $!compiled = $!compiled;
return;
}
method emit-hunk(Int $i) {
- $*result ~= @!hunks[$i][0];
+ $.emit(@!hunks[$i][0]);
+ }
+ method emit($m) {
+ $*result ~= $m;
}
- method serialize(*%attrs) {
+ method render(*%attrs) {
my $*result = '';
+ my $obj = self;
+ # XXX Needs cleanup...
+ my $*OUT = (class {
+ method say(*@args) {
+ $obj.emit($_) for (@args, "\n");
+ }
+ method print(*@args) {
+ $obj.emit($_) for @args;
+ }
+ }).new();;
eval $!compiled;
return $*result;
}
Please sign in to comment.
Something went wrong with that request. Please try again.