为大家快速提问,
是否有什么我遗漏的地方,我无法找到正确的答案,或者我正在阅读我发现错误的结果。
Bascially, I have a variable in php
ex $var="<b>#Something#</b>";
And i render it via TWIG like
{{ var }}
Run Code Online (Sandbox Code Playgroud)
我不希望它实际呈现<b>#Something#</b>,但我想要#Something#
我在简单的任务中失败的任何想法?
你可以试试raw树枝的方法
{% autoescape %}
{{ var|raw }} {# var won't be escaped #}
{% endautoescape %}
Run Code Online (Sandbox Code Playgroud)
或设置false为autoescape
{% autoescape false %}
{{ var }}{# var won't be escaped #}
{% endautoescape %}
Run Code Online (Sandbox Code Playgroud)
参考:https : //twig.symfony.com/doc/2.x/filters/raw.html