reactjs - React + Marked.js in Rails -


i'm following comments react tutorial using rails react-rails gem. consider comment component:

var comment = react.createclass({    render: function() {     return (       <div classname="comment">         <span classname="commentauthor">           <strong>{this.props.author}</strong>         </span>         <br/>         {marked(this.props.children.tostring())}       </div>     );   } }); 

which used this:

<comment author="jordan walke">this *another* comment</comment> 

the markdown correctly transformed, elements displayed if non-html-safe:

<p>this <em>another</em> comment</p> 

the component rendered in rails with

<%= react_component('commentlist', {prerender: true}) %> 

and i've tried:

<%= react_component('commentlist') %> <%= react_component('commentlist', {prerender: true}).html_safe %> 

and here's code commentlist:

var commentlist = react.createclass({    render: function() {     return (       <div classname="commentlist">         <comment author="pete hunt">this 1 comment</comment>         <comment author="jordan walke">this *another* comment</comment>       </div>     );   } }); 

so question is: how can render markdown-converted comment in html-safe way?

edit

sorry, answer right there in tutorial:

var comment = react.createclass({    render: function() {     var rawmarkup = marked(this.props.children.tostring(), {sanitize: true});     return (       <div classname="comment">         <span classname="commentauthor">           <strong>{this.props.author}</strong>         </span>         <br/>         <span dangerouslysetinnerhtml={{__html: rawmarkup}} />       </div>     );   } }); 


Comments