Incorrect rendering html template on hyperlink

326 views Asked by At

Incorrect rendering html with hyperlink data with spaces in Underscorejs Template.

When I use hyperlink with spaces in json date on underscore template. It renders the html wrongly

Eg: template:

<a href=<%-doclink%> target="_blank">,

data(json):

"doclink":"pdf/Consumerism SGO_Monthly Mailer_Apr 2015_v4.pdf",

Rendered html:

<a href="pdf/Consumerism" sgo_monthly="" mailer_apr="" 2015_v4.pdf="" target="_blank">

Please help to fix this issue

1

There are 1 answers

0
idbehold On

Change your template to use quotes around the href attribute value:

<a href="<%-doclink%>" target="_blank">