X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FTemplate%2FSimple.pm;h=4dd68a4ad7524805fa6710b8999d15930f0837ce;hb=ca30cbfe69d42d85468bd8b05ee5753cda5a009e;hp=277195bdc4f693fbfde468ae7ed07461761e1b51;hpb=89bd07c7c8709988903e8d3eb4380edc42f91c09;p=urisagit%2FTemplate-Simple.git diff --git a/lib/Template/Simple.pm b/lib/Template/Simple.pm index 277195b..4dd68a4 100644 --- a/lib/Template/Simple.pm +++ b/lib/Template/Simple.pm @@ -125,7 +125,7 @@ CODE my $code_ref = eval $source ; -die $@ if $@ ; +print $@ if $@ ; $self->{compiled_cache}{$template_name} = $code_ref ; $self->{source_cache}{$template_name} = $source ; @@ -149,13 +149,19 @@ sub _compile_chunk { # loop all nested chunks and the text separating them - while( $template =~ m{$self->{chunk_re}}g ) { + while( $template =~ m{$self->{chunk_re}} ) { # grab the pre-match text and compile its scalars and save all of its parts push @parts, $self->_compile_scalars( substr( $template, 0, $-[0] ) ) ; +# print "OFF: $-[0] $+[0]\n" ; +# print "PRE: [", substr( $template, 0, $-[0] ), "]\n\n" ; +# print "CHUNK: [$1] BODY [$2]\n\n" ; +# print "TRUNC: [", substr( $template, 0, $+[0] ), "]\n\n" ; +# print "LEFT: [$template]\n\n" ; + # compile the nested chunk and save its parts push @parts, $self->_compile_chunk( $1, $2, "$indent\t\t" ) ; @@ -163,6 +169,10 @@ sub _compile_chunk { # chop off the pre-match and the chunk substr( $template, 0, $+[0], '' ) ; + +# print "LEFT2: [$template]\n\n" ; +# print Dumper \@parts ; + } # compile trailing text for scalars and save all of its parts @@ -190,11 +200,22 @@ CODE $code .= <{$1}" ) ; + +# truncate the matched text so the next match starts at begining of string + substr( $template, 0, $+[0], '' ) ; } @@ -366,8 +390,8 @@ sub _render_hash { $rendered =~ s{$self->{chunk_re}} { # print "CHUNK $1\nBODY\n----\n<$2>\n\n------\n" ; - print "CHUNK $1\nBODY\n----\n<$2>\n\n------\n" ; - print "pre CHUNK [$`]\n" ; +# print "CHUNK $1\nBODY\n----\n<$2>\n\n------\n" ; +# print "pre CHUNK [$`]\n" ; ${ $self->_render_chunk( \"$2", $href->{$1} ) } }gex ;