如何让Twig忽略聚合物的花括号?

时间:2016-12-31 11:48:09

标签: php symfony polymer twig

我正在尝试在Twig模板中使用Polymer。但是在绑定数据时我遇到了这个问题。我无法使用{{}},因为Twig认为这是它的回音分隔符。

我们怎样才能让Twig忽略这段代码中的花括号?

  <iron-ajax auto url="http://demo.vaadin.com/demo-data/1.0/people" handle-as="json" last-response="{{peopleResponse}}"></iron-ajax>
  <vaadin-grid items="{{peopleResponse.result}}">
    <table>
      <colgroup>
        <col name="firstName"/>
        <col name="lastName"/>
        <col name="email"/>
        <col name="address.phone"/>
      </colgroup>
    </table>
  </vaadin-grid>

2 个答案:

答案 0 :(得分:3)

你可以逃脱&#39;使用{{ '{{peopleResponse}}' }}进行双花括号。

或者,您可以更改Twig echo delimiters:

$env->setLexer(new Twig_Lexer($env, [
    'tag_variable' => ['{[', ']}'],  // Now you should use {[ ]} for twig
]));

答案 1 :(得分:0)

另外一个选项是将所有Polymer代码放在Twig verbatim tags内。

{% verbatim %}
   // Polymer component code goes here
{% endverbatim %}