2016-12-31 37 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 %}