why polymer not render html markup fetched from server in json format?

Peng Kim

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 :

enter image description here enter image description here

did i miss something?

Scarygami

Polymer escapes any HTML when data-binding for security reasons. You would have to manually set the contents when the response comes in. Something like:

<core ajax ... on-core-response="{{handleResponse}}"></core-ajax>
<div id="content"></div>

...

Polymer({
   ...
   handleResponse: function (e) {
     this.injectBoundHTML(e.detail.response[0].content, this.$.content);
   }
});

See official docs for more information about this.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I render HTML in polymer that is retrieved from json?

From Dev

Render html from JSON

From Dev

Render html from JSON

From Dev

Fetching content from html and write fetched content in a specific format in CSV

From Dev

Format html from json

From Dev

Form class fails to render HTML markup - Laravel

From Dev

User Interface Markup Language (UIML) render to html

From Dev

Form class fails to render HTML markup - Laravel

From Dev

JSON fetched from URL differs

From Dev

How to render line breaks from JSON to HTML

From Dev

How can I append text fetched from ajax to my html code in a specific format?

From Dev

XPATH Needed from HTML Markup

From Dev

rails how to render two format html/json in show action of a controller

From Dev

How get text with HTML tags from server and display it in client side with HTML markup? (using php and angularjs)

From Dev

render text as html while iterating in polymer table

From Dev

In which format (HTML/markdown/JSON) should I receive some formatted text from my server?

From Dev

Format text from JSON object(server response)

From Dev

Displaying appropriate error message when data from JSON doesn't get fetched in HTML

From Dev

Data fetched from server is not getting diplayed in ReactJS

From Dev

Not able to access data in html from json format

From Dev

React js render html string returned from server

From Dev

Why doesn't HTML render when passed from AngularJS?

From Dev

Render JSON into HTML

From Dev

Render JSON into HTML

From Dev

JSoup Strip html markup from xml

From Dev

HTML markup not displaying from within php if statement

From Dev

How to render a HTML tag from json value using angularJs

From Dev

Render JSON from Rails controller into html script view partial

From Dev

make html tags render correctly from json in angular directive template

Related Related

  1. 1

    How do I render HTML in polymer that is retrieved from json?

  2. 2

    Render html from JSON

  3. 3

    Render html from JSON

  4. 4

    Fetching content from html and write fetched content in a specific format in CSV

  5. 5

    Format html from json

  6. 6

    Form class fails to render HTML markup - Laravel

  7. 7

    User Interface Markup Language (UIML) render to html

  8. 8

    Form class fails to render HTML markup - Laravel

  9. 9

    JSON fetched from URL differs

  10. 10

    How to render line breaks from JSON to HTML

  11. 11

    How can I append text fetched from ajax to my html code in a specific format?

  12. 12

    XPATH Needed from HTML Markup

  13. 13

    rails how to render two format html/json in show action of a controller

  14. 14

    How get text with HTML tags from server and display it in client side with HTML markup? (using php and angularjs)

  15. 15

    render text as html while iterating in polymer table

  16. 16

    In which format (HTML/markdown/JSON) should I receive some formatted text from my server?

  17. 17

    Format text from JSON object(server response)

  18. 18

    Displaying appropriate error message when data from JSON doesn't get fetched in HTML

  19. 19

    Data fetched from server is not getting diplayed in ReactJS

  20. 20

    Not able to access data in html from json format

  21. 21

    React js render html string returned from server

  22. 22

    Why doesn't HTML render when passed from AngularJS?

  23. 23

    Render JSON into HTML

  24. 24

    Render JSON into HTML

  25. 25

    JSoup Strip html markup from xml

  26. 26

    HTML markup not displaying from within php if statement

  27. 27

    How to render a HTML tag from json value using angularJs

  28. 28

    Render JSON from Rails controller into html script view partial

  29. 29

    make html tags render correctly from json in angular directive template

HotTag

Archive