polymer not render html tag parsed from markdown

206 views
Skip to first unread message

Peng Kim

unread,
Apr 17, 2015, 6:12:36 AM4/17/15
to polym...@googlegroups.com
my custom element:

<core-ajax auto method="GET" url="http://example.com/book" handleAs="json" response="{{response}}"></core-ajax>
      <core-header-panel mode="cover" layout horizontal flex>   
        <div  class="core-header tall">{{articlename}}</div>
        <div  class="content" flex >
          {{response[0].content}}
        </div>
</core-header-panel>
content in db was stored in markdown format,it will be transformed to html markup when requested,this process was fine,i got the transformed html markup,but when it dynamically inserted into the page, the html markup wasn't rendered whereas original html tag .

markdown to html:(i use django-markdown-deux)
markdown(content)
original data from db:
[{"id":4,"title":"css 1","category":"CSS","articletags":["sa","asd"],"content":"*asdsdsasadsa*\r\n\r\n    sdsadsadssdsasdsa","like":0,"createtime":"2015-04-17T05:58:01Z"}]
parsed data from db:
[{"id":4,"title":"css 1","category":"CSS","articletags":["sa","asd"],"content":"<p><em>asdsdsasadsa</em></p>\n\n<pre><code>sdsadsadssdsasdsa\n</code></pre>\n","like":0,"createtime":"2015-04-17T05:58:01Z"}]
and result is :



Tomek W

unread,
Apr 18, 2015, 4:50:51 PM4/18/15
to polym...@googlegroups.com
You can try https://github.com/Juicy/juicy-markdown to parse and render markdown:
<juicy-markdown value="{{markdowncontent}}"></juicy-markdown>

Or https://github.com/Juicy/juicy-html to render already parsed markdown HTML:
<juicy-html content="{{htmlcontent}}"></juicy-html>

Best regards,
Tomek

Peng Kim

unread,
Apr 19, 2015, 12:18:11 AM4/19/15
to polym...@googlegroups.com
sure,thanks for recommendations,but my real problem is that polymer escapes any html when data-biding for security reason,i should use this.injectBoundHTML(e.detail.response[0].content, this.$.content);

Tomek W

unread,
Apr 19, 2015, 12:59:05 PM4/19/15
to polym...@googlegroups.com
YW,
That's what for we have created `<juicy-html>` http://juicy.github.io/juicy-html/examples/template_inline.html
We do not use `injectBoundHTML` as we have created custom element long before it was provided, and right now we are not sure how it will evolve with Polymer >= 0.8, plus we would like to make it library agnostic.

Peng Kim

unread,
Apr 21, 2015, 6:40:01 AM4/21/15
to polym...@googlegroups.com
OK,thanks,i will have a try,i have a big problem with polymer 0.5, they only worked well on chrome,but firefox,safari,IE,they make me crazy,can you help me to point out where i was doing wrong  or not appropriate,if can,i will provicde my site url,its rather simple,will not waste of your time.
Reply all
Reply to author
Forward
0 new messages