This is a migrated thread and some comments may be shown as answers.

templates with localized data - Uncaught Error: Invalid template:

2 Answers 115 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 04 Sep 2014, 11:35 PM
Here's my template (from my .cshtml file):

<script id="row-checkbox-template" type="text/x-kendo-tmpl">
    <div style="text-align:center;">
    <input type="checkbox" class="chkRow" data-id="#=TransactionId#" #if (!IsEditable) {# disabled="disabled" #} else {# tabindex="0" #}# title="@AssignCategories.SelectRow" />
    </div>
</script>

In en-US locale, all works great, now I'm testing fr-CA and I'm getting "Uncaught Error: Invalid template."  I remove the localized text from the title attribute in the template and it works great.  BTW, the fr-CA value for the title that is causing the issue is: "Sélectionner une ligne".

How do I properly encode this value in the template?

Thanks,
--Ed

2 Answers, 1 is accepted

Sort by
0
Ed
Top achievements
Rank 1
answered on 04 Sep 2014, 11:44 PM
and here is the exception (in the Chrome Console):

Uncaught Error: Invalid template:'
    <div style="text-align:center;">
    <input type="checkbox" class="chkRow" data-id="#=TransactionId#" #if (!IsEditable) {# disabled="disabled" #} else {# tabindex="0" #}# title="S&#233;lectionner une ligne" />
    </div>
' Generated code:'var o,e=kendo.htmlEncode;with(data){o='\n    <div style="text-align:center;">\n    <input type="checkbox" class="chkRow" data-id="'+(TransactionId)+'" ';if (!IsEditable) {;o+=' disabled="disabled" ';} else {;o+=' tabindex="0" ';};o+=' title="S&';233;lectionner une ligne" />
    </div>
;o+=;}return o;' 
0
Ed
Top achievements
Rank 1
answered on 05 Sep 2014, 12:11 AM
Fixed the problem using Html.Raw like this...

@Html.Raw(AssignCategories.SelectRow)
Tags
Templates
Asked by
Ed
Top achievements
Rank 1
Answers by
Ed
Top achievements
Rank 1
Share this question
or