while( my( $parsed_name, $parsed_body ) =
$template =~ m{$self->{chunk_re}} ) {
+ my $chunk_left_index = $-[0] ;
+ my $chunk_right_index = $+[0] ;
+
# get the pre-match text and compile its scalars and text. append to the code
$code .= $self->_compile_scalars(
- substr( $template, 0, $-[0] ), $indent ) ;
+ substr( $template, 0, $chunk_left_index ), $indent ) ;
-# 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" ;
+# print "TRUNC: [", substr( $template, 0, $chunk_right_index ), "]\n\n" ;
+# print "PRE: [", substr( $template, 0, $chunk_left_index ), "]\n\n" ;
+
+# chop off the pre-match and the chunk
+
+ substr( $template, 0, $chunk_right_index, '' ) ;
+
+# print "REMAIN: [$template]\n\n" ;
# compile the nested chunk and append to the code
$code .= $self->_compile_chunk(
$parsed_name, $parsed_body, $indent
) ;
-
-# chop off the pre-match and the chunk
-
- substr( $template, 0, $+[0], '' ) ;
}
# compile trailing text for scalars and append to the code
return $compiled->($data) ;
}
-# not compiled so get this template by name
-
- $tmpl_ref ||= eval{ $self->_get_template($template_name) } ;
-
-# we couldn't find this template name so assume it is the template text
+# not compiled so try to get this template by name or
+# assume the template name are is the actual template
- $tmpl_ref ||= \$template_name ;
+ $tmpl_ref =
+ eval{ $self->_get_template($template_name) } ||
+ \$template_name ;
}
my $rendered = $self->_render_includes( $tmpl_ref ) ;