问题描述
我试图在一个 XML 模板中输出一些 HTML,而 Symfony 的转义方法把它搞砸了.所以我尝试在模块的 config 文件夹中制作 settings.yml 的副本,但它似乎被完全忽略了.是否有一种简单的方法可以更改每个模块甚至每个模板的 escaping_strategy 和/或 escaping_method 设置?
I'm trying to output some HTML in an XML template and Symfony's escaping method is messing it up. So I tried making a copy of settings.yml in the module's config folder, but it seems to be completely ignored. Is there an easy way to change the escaping_strategy and/or escaping_method settings per module or even per template?
推荐答案
当输出转义打开时,您仍然可以通过 $sf_data
访问原始值.例如,如果您尝试输出的 HTML 存储在您的操作中名为 html 的变量中:
While output escaping is turned on you still have access to the raw value through $sf_data
. For example, if the HTML you're trying to output was stored in a variable called html in your action:
$this->html = '<b>My HTML</b>';
您可以通过以下方式获得未转义的值:
You could get the unescaped value with this:
<?php echo $sf_data->getRaw('html') ?>
我认为没有办法在每个模块的基础上禁用此功能.
I don't believe there is a way to disable this functionality on a per-module basis.
这篇关于Symfony - 是否可以禁用每个模块(或每个模板)的输出转义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!