2005年1月28日金曜日

Template::Toolkit - 文字列の連結

Template::Toolkitのテンプレート内の文字列の連結は'_'(アンダースコア)を使う。忘れるのでメモ。

Template Toolkit Manual

You can concatenate strings together using the ' _ ' operator. In Perl 5, the '.' is used for string concatenation, but in Perl 6, as in the Template Toolkit, the '.' will be used as the method calling operator and ' _ ' will be used for string concatenation. Note that the operator must be specified with surrounding whitespace which, as Larry says, is construed as a feature:
[% copyright = '(C) Copyright' _ year _ ' ' _ author %]
You can, of course, achieve a similar effect with double quoted string interpolation.
[% copyright = "(C) Copyright $year $author" %]



0 件のコメント:

コメントを投稿