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

Template is not working with html encoded symbols (like ')

13 Answers 513 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Volodymyr
Top achievements
Rank 1
Volodymyr asked on 10 Sep 2014, 12:40 PM
Hello,

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

Sort by
0
Petyo
Telerik team
answered on 11 Sep 2014, 06:39 AM
Hello,

the # symbols are expression delimiters. You should escape them with a \ prefix. Please refer to our documentation for more details. 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Oleksandr
Top achievements
Rank 1
answered on 17 Jan 2017, 07:24 PM

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...

0
Oleksandr
Top achievements
Rank 1
answered on 18 Jan 2017, 10:38 AM

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.

0
Stefan
Telerik team
answered on 19 Jan 2017, 01:03 PM
Hello Oleksandr,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
0
Oleksandr
Top achievements
Rank 1
answered on 19 Jan 2017, 07:46 PM

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?

0
Stefan
Telerik team
answered on 23 Jan 2017, 09:46 AM
Hello Oleksandr,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
0
Oleksandr
Top achievements
Rank 1
answered on 23 Jan 2017, 10:51 AM
My email is oleksandr.pshenychny@eleks.com
0
Stefan
Telerik team
answered on 23 Jan 2017, 12:00 PM
Hello Oleksandr,

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. 
Regards,
Stefan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
0
Oleksandr
Top achievements
Rank 1
answered on 23 Jan 2017, 12:03 PM

Thank you, Stefan!

That was a link to this forum in fact =). Nevertheless, I understand the problem.

0
Oleksandr
Top achievements
Rank 1
answered on 23 Jan 2017, 12:14 PM
And my account is blocked again... This time I didn't use any URLs in my post... What was wrong this time?
Why don't you have some kind of validation instead of blocking account immediately?
0
Stefan
Telerik team
answered on 23 Jan 2017, 12:24 PM
Hello Oleksandr,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
0
Dina
Top achievements
Rank 1
answered on 11 Apr 2017, 02:32 AM
this is issue. If I use national symbols in Model it breaks EditTemplates generating invalid template error. All national symbols translated to а
0
Tsvetina
Telerik team
answered on 13 Apr 2017, 09:02 AM
Hi Dima,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Templates
Asked by
Volodymyr
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Oleksandr
Top achievements
Rank 1
Stefan
Telerik team
Dina
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or