如何在表单原始函数树枝中对var中的字符串html进行转义?

问题描述

我想在下面的变量help中取消使用字符,但是我无法在form_raw()中对其进行编码

我尝试过这种方式:

{% set help %} {% include 'front/partials/help-bubble.twig' %} {% endset %}

{% autoescape false %}
     {{ (form_row(form.password.first,{
         label: transcap('password') ~ help
      }))|raw }}
 {% endautoescape %} 

寻求帮助;)

解决方法

不要转义整个内容,请尝试仅转义要转义的变量

{% autoescape false %}
     {{ (form_row(form.password.first,{
         label: (transcap('password') ~ help)|raw
      })) }}
 {% endautoescape %}