Created
July 9, 2011 15:06
-
-
Save toritori0318/1073642 to your computer and use it in GitHub Desktop.
xslate : my の扱いについて
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # perlversion = 5.14.1 | |
| # Text::Xslate = 1.3000 | |
| use strict; | |
| use Text::Xslate; | |
| my $tx = Text::Xslate->new(); | |
| my %vars = ( | |
| title => 'A list of books', | |
| books => [ | |
| { title => 'Islands in the stream' }, | |
| { title => 'Programming Perl' }, | |
| ], | |
| fuga => 'fugaaaaaaaaaaaaaaaaa', | |
| ); | |
| # for strings | |
| my $template = q{ | |
| : my $hoge = 'hogeee'; | |
| <p> <: $hoge :> </p> | |
| : if $hoge == 'hogeee' { | |
| #### TRUE1 | |
| : } else { | |
| #### FALSE1 | |
| : } | |
| : for $books -> $book { | |
| <h1> <: $hoge :> </h1> | |
| : if $hoge == 'hogeee' { | |
| #### TRUE2 | |
| : } else { | |
| #### FALSE2 | |
| : } | |
| <h2> <: $fuga :> </h2> | |
| <li><: $book.title :></li> | |
| : } # for | |
| }; | |
| print $tx->render_string($template, \%vars); | |
| __END__ | |
| ##################################################### | |
| # % perl xslate_my_test.pl | |
| # | |
| # <p> hogeee </p> | |
| # | |
| # #### TRUE1 | |
| # | |
| # | |
| # | |
| # | |
| # <h1> </h1> | |
| # #### FALSE2 | |
| # | |
| # <h2> fugaaaaaaaaaaaaaaaaa </h2> | |
| # <li>Islands in the stream</li> | |
| # | |
| # <h1> </h1> | |
| # #### FALSE2 | |
| # | |
| # <h2> fugaaaaaaaaaaaaaaaaa </h2> | |
| # <li>Programming Perl</li> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment