1
1

More than 3 years have passed since last update.

smartyでhtml形式の変数をhtmlとして表示する3つの方法

Last updated at Posted at 2020-08-25

smartyでhtml形式の変数をhtmlとして
表示するための方法を調べていていくつかパターンがあり、
環境によって適応できる形式が異なるようなのでまとめました。

例えば

$test = '<b>こんにちは<b>'

というhtml変数があったとして

<b>こんにちは<b>

ではなく

こんにちは

というように太字で表示させたい(htmlを反映させたい)時の出力方法です。

いくつかのサイトを見ましたが以下の3つのうち、1つしか書いていない記事が多く混乱したのでまとめました。
以下の3パターンを試せばどれかでうまくいくと思います。

  • {$test nofilter}

  • {$test|smarty:nodefaults}

  • {$test|unescape}

もし他のパターンがあれば教えてください!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1