Escape both single quote and double quote in Smarty

Oddly it seems that when using {$foo|escape:'quotes'} Smarty will only escape single quotes instead of both single and double quotes. This is problematic with HTML attributes that need the " changed to &quote;.

Double quotes can be escaped using {$foo|escape:'html'}, but it doesn't work for single quote.

We can use this way to escape both single and double quotes: {$foo|escape:'quotes'|replace:'"':'"'}

Also, we can write a custom modifier:

 

發佈了33 篇原創文章 · 獲贊 1 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章