编码不适用于风格应用

时间:2018-05-30 08:21:13

标签: css twig

我正在使用symfony,在我的控制器中我有类似的东西:

 $colors =" test > test2{
         color : #fff
         }";
 return $this->render(
        'Default/views/page.html.twig',
        array("colors" =>$colors)
       );

在我的树枝上我有:

 <style>
      {{ colors }}
 </style>

但问题是>而不是&gt;,所以我的风格不适用。 但如果我在{{ colors }}之外script我正确地>

1 个答案:

答案 0 :(得分:1)

出于安全原因,

colors var已转义,如果您确定要执行的操作,则必须使用{{ colors|raw }}

请参阅https://twig.symfony.com/doc/2.x/filters/raw.html