Render string that has HTML
-
I have a string that has embedded html and I am trying to render it. I normally use something like: <div dangerouslySetInnerHTML={{ __html: string }}/>
I can't get this to work in jsreport since the double bracket tells JS Report that the __html is a function.
Is is there a way to have js report render the string a html???
I need something like <div dangerouslySetInnerHTML={{ __html: {{myString}} }}/>.. which just blows up
-
hi! it depends on the engine that you are using. if you are using handlebars you can use triple bracket to tell handlebars to not escape html
{{{myString}}}
, however it seems your react.js syntax is messing with handlebars so you need to tell handlebars to not process the{{ _html
part, so the final syntax that should work is this:<div dangerouslySetInnerHTML=\{{ __html: {{{myString}}} }}></div>
-
Well, you solve it ! :) .. interestingly enough I just used the triple bracket and it worked PERFECT. I did not even have to use the div.. very nice.. I did not know the {{{ even existed.. very nice.. thank you !