kendo template changing html entities when 'render as html' is used

1 Answer 30 Views
Templates
Chris
Top achievements
Rank 1
Chris asked on 17 Aug 2021, 06:27 PM

The kendo template function injects the literal " value into the DOM instead of " when the html encoding template format is used.  For example:

var template = kendo.template("<div id='box'>#= firstName #</div>");
var data = { firstName: "<b>Todd'\" &amp; &quot; &#34; &#x00022; </b>" };

results in the following value being inserted into the DOM:

<b>Todd'" &amp; " " " </b>

Why are the 3 html entity representations of double quotes translated back to the double quote literal?  Is there a way to avoid this?  If not, what other html entities behave this way?  

http://jsfiddle.net/6fcz2e9j/1/

 

 

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 23 Aug 2021, 06:06 AM

Hello, Chris,

I already answered the initial question in the support thread you opened on the subject, but I will also share my reply here.

Please refer to the code snippet below to see how to encode the data and the difference with example you provided:

var template = kendo.template("<div id='box'>#: firstName #</div>"); // ---> HTML is encoded
var template = kendo.template("<div id='box'>#= firstName #</div>"); // ---> HTML is not encoded

Here is the modified example for reference. You can also review our Templates documentation for further information.

Regards,
Martin
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Templates
Asked by
Chris
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or