In my application we are using backbone.js for MV* type functionality. IT performs navigation events based on hash (#) in a URL. So for example entering in #profile brings up your profile. We are using a KendoUI template in a grid (since I couldn't get other templates to work right). Is there anyway to escape a # that may appear in the template?
11 Answers, 1 is accepted
The getting started / templates article in our documentation describes the escaping syntax in strings and script templates in details.
Regards,Petyo
the Telerik team
I believe in my case I was using a literal string. How do I escape it when using a literal string (#= .. # format)
Unless I am missing something, I don't think you need any sort of a special treatment for the strings in the template (escaping # symbols, etc). If you still experience troubles with this, can you prepare a small example? We will check it out and do our best to help.
All the best,Petyo
the Telerik team
I am not sure what is the problem in the bin provided. Can you please elaborate a bit?
Regards,Petyo
the Telerik team
This is not a valid template. The #= # expression should contain a valid JavaScript identifier which "#" by itself isn't. Here is the updated demo with a valid template and values containing "#": http://jsbin.com/ivivac/5/edit
All the best,Atanas Korchev
the Telerik team
http://jsbin.com/ivivac/6/
Basically, we want # to appear in front of the value in the model of the datasource.
In that case you just need to put the # outside of the #= # expression:
rowTemplate:kendo.template("<tr><td>\\# #= value #</tr>"),
Here is the updated example: http://jsbin.com/ivivac/7/edit
Atanas Korchev
the Telerik team
I provided a working version of the demo. Did you check it out? It shows how to escape a "#" in a template definition. And yes, you cannot have "#" inside a "#= #" expression.
Regards,Atanas Korchev
the Telerik team