Show
Ignore:
Timestamp:
11/25/08 09:54:56 (4 years ago)
Author:
tokuhirom
Message:

merge from NanoA.see http://d.hatena.ne.jp/kazuhooku/20081121/1227267264

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/MENTA/trunk/lib/MENTA/Template.pm

    r23957 r24791  
     1# a NanoA version 
    12# based on Mojo::Template. Copyright (C) 2010, Sebastian Riedel. 
    23# some modified by tokuhirom 
     
    5960            # Expression 
    6061            if ($type eq 'expr') { 
    61                 $lines[-1] .= "\$_MENTA .= escape_html(scalar $value);"; 
     62                $lines[-1] .= "\$_MENTA_T = scalar $value; \$_MENTA .= ref \$_MENTA_T eq 'MENTA::Template::RawString' ? \$\$_MENTA_T : escape_html(\$_MENTA_T);"; 
    6263            } 
    6364 
    6465            # Raw Expression 
    6566            if ($type eq 'raw_expr') { 
    66                 $lines[-1] .= "\$_MENTA .= $value;"; 
     67                 
     68                $lines[-1] .= "\$_MENTA_T = $value; \$_MENTA .= ref \$_MENTA_T eq q(MENTA::Template::RawString) ? \$\$_MENTA_T : \$_MENTA_T;"; 
    6769            } 
    6870        } 
     
    7173    # Wrap 
    7274    $lines[0] ||= ''; 
    73     $lines[0]   = q/sub { my $_MENTA = '';/ . $lines[0]; 
     75    $lines[0]   = q/sub { my $_MENTA = ''; my $_MENTA_T = '';/ . $lines[0]; 
    7476    $lines[-1] .= q/return $_MENTA; }/; 
    7577 
     
    270272} 
    271273 
     274# create raw string (that does not need to be escaped) 
     275sub raw_string { 
     276    my $s = shift; 
     277    bless \$s, 'MENTA::Template::RawString'; 
     278} 
     279 
    2722801;