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

14 posts, 0 answers
  1. Volodymyr
    Volodymyr avatar
    11 posts
    Member since:
    May 2012

    Posted 10 Sep 2014 Link to this post

    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
  2. Petyo
    Admin
    Petyo avatar
    2444 posts

    Posted 11 Sep 2014 Link to this post

    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!
     
  3. Oleksandr
    Oleksandr avatar
    13 posts
    Member since:
    Oct 2008

    Posted 17 Jan Link to this post

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

  4. Oleksandr
    Oleksandr avatar
    13 posts
    Member since:
    Oct 2008

    Posted 18 Jan Link to this post

    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.

  5. Stefan
    Admin
    Stefan avatar
    1033 posts

    Posted 19 Jan Link to this post

    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 second 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 visualization (charts) and form elements.
  6. Oleksandr
    Oleksandr avatar
    13 posts
    Member since:
    Oct 2008

    Posted 19 Jan in reply to Stefan Link to this post

    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?

  7. Stefan
    Admin
    Stefan avatar
    1033 posts

    Posted 23 Jan Link to this post

    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 visualization (charts) and form elements.
  8. Oleksandr
    Oleksandr avatar
    13 posts
    Member since:
    Oct 2008

    Posted 23 Jan in reply to Stefan Link to this post

    My email is oleksandr.pshenychny@eleks.com
  9. Stefan
    Admin
    Stefan avatar
    1033 posts

    Posted 23 Jan Link to this post

    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 visualization (charts) and form elements.
  10. Oleksandr
    Oleksandr avatar
    13 posts
    Member since:
    Oct 2008

    Posted 23 Jan in reply to Stefan Link to this post

    Thank you, Stefan!

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

  11. Oleksandr
    Oleksandr avatar
    13 posts
    Member since:
    Oct 2008

    Posted 23 Jan in reply to Stefan Link to this post

    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?
  12. Stefan
    Admin
    Stefan avatar
    1033 posts

    Posted 23 Jan Link to this post

    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 visualization (charts) and form elements.
  13. Dima
    Dima avatar
    48 posts
    Member since:
    Feb 2012

    Posted 10 Apr Link to this post

    this is nasty issue. If I use national symbols in Model it breaks EditTemplates generating invalid template error. All national symbols translated to а
  14. Tsvetina
    Admin
    Tsvetina avatar
    2076 posts

    Posted 13 Apr Link to this post

    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.
Back to Top