Created
November 12, 2014 03:07
-
-
Save nanto/27c25094ba7788da50f3 to your computer and use it in GitHub Desktop.
Text::Xslate::TTerse の undocumented な動作
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
Out of WRAPPER | |
[%- WRAPPER 'wrapper.tt' WITH arg1 = var, arg2 = 'literal' -%] | |
arg2: [% arg2 %] | |
[%- END -%] |
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
use strict; | |
use warnings; | |
use Text::Xslate; | |
my $tx = Text::Xslate->new(syntax => 'TTerse', cache => 0); | |
print $tx->render('content.tt', { var => 42 }); |
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
arg1: [% arg1 %] | |
content: [% content %] |
いずれの挙動も、今後互換性を壊す変更はしないつもりです。この挙動をテストするコードをpull-requestでいただけると、意図せず壊すこともなくなります。
具体的には、1はドキュメント化されてないだけで想定どおりの挙動、2はドキュメントの間違い、3は意図しない挙動でたまたま動いているだけですがいまの振る舞いを変更すべきでない、とそれぞれステータスは違うのですが、互換性を壊す変更をするつもりがないという点では一致しています。
回答ありがとうございます。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
render.pl
の実行結果は:ここから 3 つの文書化されていない挙動がうかがえる。
WRAPPER
ステートメントの外側の記述 (Out of WRAPPER
) は無視される。WRAPPER
ステートメントの外側に関する記述はない。WRAPPER
ステートメントの引数 (arg1
) に変数 (var
) を渡せる。WRAPPER
ステートメントの内容において、引数 (arg2
) を変数のように扱える。