String.Replace in Template

2 posts, 1 answers
  1. Kristian
    Kristian avatar
    16 posts
    Member since:
    Jun 2010

    Posted 14 Feb 2012 Link to this post

    I want to replace a character a string within a template, is there a way I can do that?

    I tried the following but get an invalid template
    <script id="template" type="text/x-kendo-template">
        #= kendo.toString(replaceString(#= Name #))#
    <script type="text/javascript">
        function replaceString(value) {
            return value.replace(",", "<br />");
  2. Answer
    Rosen avatar
    3215 posts

    Posted 15 Feb 2012 Link to this post

    Hi Kristian,

    Indeed, the code you have pasted will generate an invalid template. As the expression is already wrapped within a "code block" you do not need the nested pound signs:

    <script id="template" type="text/x-kendo-template">
        #= kendo.toString(replaceString(Name))#

    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top