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

String.Replace in Template

1 Answer 2260 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Kristian
Top achievements
Rank 2
Kristian asked on 14 Feb 2012, 06:36 PM
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>
 
<script type="text/javascript">
    function replaceString(value) {
        return value.replace(",", "<br />");
    }
</script>

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 15 Feb 2012, 08:49 AM
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))#
</script>

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Templates
Asked by
Kristian
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Share this question
or