1

I am using Symfony2 Framework. For view part, I am using Reactjs. Since, twig also uses '{{' and '}}', So to use '{{' in twig , I am doing following:

<div {{'dangerouslySetInnerHTML={{__html: this.props.html}}'}}></div>

and

<div style={{'{{width:10}}'}}

When I try to transform this jsx into js, I get error wherever I have used braces for twig. How to transform a jsx code having twig variables and twig braces into JS?

EDIT: here is the twigfiddle . If I try to transform this code to js using JSX compiler , then I get error: Error: Parse Error: Line 4: Unexpected token %

programmer
  • 324
  • 8
  • 22
  • 1
    have you already see the [verbatim tag](http://twig.sensiolabs.org/doc/tags/verbatim.html)? – Matteo Sep 02 '15 at 09:58
  • Even if I use verbatim, then Error will be shown for {%verbatim%} . The transformer will give unexpected token error as soon as it will see '{%' – programmer Sep 02 '15 at 10:00
  • sorry i don't understand the problem... check if this can help you http://stackoverflow.com/questions/13671701/angularjs-twig-conflict-with-double-curly-braces/13671817#13671817 – Matteo Sep 02 '15 at 10:02
  • SOrry for bad english. I want to transform JSX to JS. and because of use of twig, The transformer is unable to change jsx to js. So I want some work around – programmer Sep 02 '15 at 10:07
  • i don't understand the problem because i don't know more about reactjs and jsx! :) – Matteo Sep 02 '15 at 10:12
  • 2
    ca you replicate the problem in a [twigfiddle](http://twigfiddle.com/)? – Matteo Sep 02 '15 at 10:18
  • [twigfiddle](http://twigfiddle.com/0s0xpr) If I try to transform this code to js using [JSX compiler](https://facebook.github.io/react/jsx-compiler.html) , then I get error: Error: Parse Error: Line 4: Unexpected token % – programmer Sep 02 '15 at 10:29

0 Answers0