I have MVC application that inserts some texts into the grid template.
MVC encodes quotes (') to (') and it is fine but after that the template stops working!
Here is an example: http://jsfiddle.net/GFV52/8/
Why the template cannot work with html encoded symbols and how to fix this?
Vova
13 Answers, 1 is accepted
the # symbols are expression delimiters. You should escape them with a \ prefix. Please refer to our documentation for more details.
Regards,
Petyo
Telerik
Hello Petyo,
Don't you think that choosing '#' as expression delimiter for kendo templates was not the best idea? As Volodymyr pointed, this conflicts with HTML encoding.
Many platforms do HTML encoding very simple (e.g in MVC I write @Localization.Get("aaa")). But I have to remember every time that it would have worked in regular HTML, and not in kendo template HTML. Kendo MVC seem to not have standard extension method for template-encoding (which is strange, although not hard to implement manually). But anyway syntax start looking weird and there is no way to simplify it:
@Html.Raw(Html.Kendo().TemplateEncode(Localization.Get("aaa"))).
And this string must be copied again and again into every template, every server-included string. Crazy.
It would make much less problems if you used different symbol ('$' maybe, or at least doubled '##'...). It would make situations, requiring additional encoding extreemely rare (although I understand it's not 100% reliable solution, but it's far better than current approach).
Is there any chance you will change that in the near future (maybe support another template type "text/x-kendo-template2")?
PS: You can imagine what would happen if my template is written inline in javascript piece inside razor view - 3rd encoding level...
I'm unable to edit my reply, so have to add another one to fix the bug (forgot Html encoding the string)...
So, instead of writing
@Localization.Get("aaa")
I have to use
@Html.Raw(Html.Kendo().TemplateEncode(Html.Encode(Localization.Get("aaa"))))
for every localization string I have in kendo templates (since any string may contain unicode characters in some language).
If you had '##' or '$' as expression delimiter, simple @Localization.Get("aaa") would work in 99.9% of cases.
Thank you for your feedback.
The suggestion is reasonable and valid, but changing the current behaviour of the templates will result in a major breaking change and changing it in the future is unlikely.
Still, I will forward your request for making type of templates which can use a different syntax.
Also, I can suggest submitting a feature request in our UserVoice portal describing the request:
http://kendoui-feedback.telerik.com/forums/127393-kendo-ui-feedback
Regards,
Stefan
Telerik by Progress
Hello Stefan,
I actually added the suggestion on UserVoice portal yesterday, but it did not appear there till today. I tried again today, but now it says "You have been blocked" and does not allow to log in. My happiness of finally (after 2 years!) having all my forum posts not being considered as spam was short - I'm blocked now in another way :(.
As for the topic, I think you actually could do a pretty reliable fix to current templates syntax as well - just not treat HTML-encoded symbols (regex '&#\d+;') as template delimiters.
Having less conflicting template syntax text/x-kendo-template2 would still be a better solution, but for the time being the aforementioned fix is a must have.
Could you log this request some where for me, or unblock my account please?
I will check in the system, the reason for blocking the account.
Could you please share with me the email address which was used in the portal, so I can locate the profile?
Regards,
Stefan
Telerik by Progress
The account is unblocked already.
Please have in mind, that some texts can be evaluated to not allowed links, which can cause blocking the account.
Apologies for the inconvenience, now you can share the request with the community and the developers' team.
Stefan
Telerik by Progress
Thank you, Stefan!
That was a link to this forum in fact =). Nevertheless, I understand the problem.
Why don't you have some kind of validation instead of blocking account immediately?
The reason this and the previous blocking was adding asp.net which is evaluated as a link to the ASP site:
https://www.asp.net/
Thank you for the validation suggestion, but we do not have a full control over it as it is a third-party service.
The account is unblocked again.
Regards,
Stefan
Telerik by Progress
Currently, the changes suggested by Oleksandr have not been added to Kendo UI, so what has been discussed below is still valid. You will need to escape # signs in the template.
You can vote for the feature suggestion added by Oleksandr here, as it is already getting upvotes and if they keep growing this way, his suggestion may get scheduled for implementation.
Regards,
Tsvetina
Telerik by Progress