[英]Symfony2: How to replace a certain string with a global Twig variable?
[英]Is there a way to replace a string with html tags in TWIG (Symfony2)?
我在數據庫中保存了一個html,帶有一個特殊的標記字符串,例如[special_tag],我想同時將該html顯示到我的樹枝模板中,並用任何html元素替換[special_tag]。
這可能嗎?
是的,您可以使用Twig的replace
過濾器 :
{{ my_variable_with_html | replace({'[special_tag]': 'new value'}) }}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.