2016-12-31 81 views
2

我想在树枝模板中使用聚合物。但是在绑定数据时我遇到了这个问题。我无法使用{{}},因为Twig认为这是它的echo分隔符。如何让树枝忽略用于聚合物的花括号?

我们该如何让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> 

+0

重复http://stackoverflow.com/questions/12497130/how-to-escape-twig-delimiters-in-a-twig-template –

回答

3

你可以 '逃离' 双花括号使用{{ '{{peopleResponse}}' }}

或者,你可以改变枝条回声分隔符:

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

现在,做工精细。谢谢彼得,弗兰克B – sankar

0

一个附加选项是把里面所有Twig verbatim tags高分子代码。

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