Smarty 変数の修飾子

変数の修飾子の例一覧

Smarty

{* 単語の頭を大文字 「foo」を「Foo」に置換。 *} {$str|capitalize} {* 文字を連結 「foo」を「foobaz」に置換。 *} {$str|cat:'baz'} {* 文字数 「foo」の場合、3を返す。 *} {$str|count_characters} {* パラグラフ数 「foo bar baz」の場合、3を返す。 *} {$str|count_paragraphs} {* センテンスの数 「foo. bar. baz.」の場合、3を返す。 *} {$str|count_sentences} {* 単語の数 「foo bar baz」の場合、3を返す。 *} {$str|count_words} {* 日付フォーマット 2024/01/02 20:43:23 *} {$date|date_format:'%Y/%m/%d %H:%M:%S'} {* 月と日を0詰め 2024/1/2 20:43:23 *} {$date|date_format:'%Y/%-m/%-d %H:%M:%S'} {* January 2, 2024 *} {$date|date_format:'%B %-d, %Y'} {* 240102 *} {$date|date_format:'%y%m%d'} {* Smartyでのprint_r、var_dump *} {$str|debug_print_var} {* 5階層、値は10字まで(1234567...) *} {$str|debug_print_var:5:10} {* デフォルトを指定 *} {$str|default:'0'} {* エスケープ処理 「<b>foo</b>」を「&lt;b&gt;foo&lt;/b&gt;」に置換。 *} {$str|escape} {* メールアドレスをエスケープ *} {$str|escape:'mail'} {* インデントを指定(半角スペース4つ分) 「foo」を「 foo」に置換。 *} {$str|indent} {* インデントを5スペース分指定 「foo」を「 foo」に置換。 *} {$str|indent:5} {* 小文字 「FOO」を「foo」に置換。 *} {$str|lower} {* 改行 *} {$str|nl2br} {* 置換 *} {$str|regex_replace:'/[\r\t\n]/':' '} {* 「foo bar」を「foo bar」に置換。 *} {$str|replace:' ':' '} {* スペース追加 「foo」を「f o o」に置換。 *} {$str|spacify} {* フォーマット 「01」を「1」に置換。 *} {$str|string_format:'%d'} {* 空白・改行・タブを置換 「foo bar」を「foo&nbsp;bar」に置換。 *} {$str|strip:'&nbsp;'} {* タグ削除、スペースに置換 「<b>foo</b>」を「 foo 」に置換。 *} {$str|strip_tags} {* タグ削除 「<b>foo</b>」を「foo」に置換。 *} {$str|strip_tags:false} {* 文字列切捨 「foo bar baz qux quux foobar corge grault garply waldo fred plugh xyzzy thud」を「foo bar baz qux quux foobar corge grault garply...」に置換。*} {$str|truncate:50:'...'} {* 大文字 「foo」を「FOO」に置換。 *} {$str|upper} {* ワードラップ 「foo bar baz qux quux foobar corge grault garply waldo fred plugh xyzzy thud」を「foo bar baz qux quux foobar corge grault garply waldo fred plugh xyzzy thud」に置換。 *} {$str|wordwrap:50}

最新の記事

プロフィール

流されるままにウェブ業界で仕事しています。主にLAPP環境でPHPを書いています。最近はjQueryで遊んでいます。
※動作確認について