|
#title("Template-Toolkit - 文法") Template-Toolkit (文法)文字列結合[% 'a' _ 'b' %] http://search.cpan.org/perldoc?Template::Manual::Directives IF [% IF foo %]
..............
[% ELSIF bar %]
..............
[% ELSE %]
..............
[% END %]
配列[% users.0 %] [% users.1 %] [% num = users.size %] ハッシュキーを変数にして参照する[% attr = 'age' %] [% user.$attr %] # same as [% user.age %] ループで参照する[% FOREACH key IN hash.keys %] - [% key %] [% END %] [% FOREACH key IN hash.keys.sort %] - [% key %] [% END %] [% FOREACH pair IN product.pairs %] - [% pair.key %] / [% pair.value %] [% END %] 配列・ハッシュのマニュアルhttp://search.cpan.org/perldoc?Template::Manual::VMethods ループ [% FOREACH i IN items %]
[% i %] [% loop.index() %] # loopオブジェクトはFOREACHに標準で組み込まれたオブジェクト
[% END %]
[% WHILE (user = get_next_user_record) %]
[% user.name %]
[% END %]
loopオブジェクトのメソッド
http://search.cpan.org/perldoc?Template::Manual::Directives フィルター改行コードをBRタグへ<p>[% bar | html_line_break %]</p> 参考http://search.cpan.org/perldoc?Template::Manual::Filters コメント [% # this is a comment to the end of line
foo = 'bar'
%]
[%# placing the '#' immediately inside the directive
tag comments out the entire directive
%]
http://search.cpan.org/perldoc?Template インクルード・インサートTTファイルをインクルード [% INCLUDE header.tt %] HTMLファイルをインクルード [% INSERT "$DOC_ROOT/footer.html" %]
参考http://search.cpan.org/perldoc?Template::Manual::Directives 関数配列のjoin() [% items.join(', ') %]
配列のサイズ[% results.size %] |
|