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

Escaping # with new syntax

1 Answer 4115 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 12 Oct 2011, 05:43 PM
Is there a way to escape # to use it as part of a hex color literal in a template?

I have several situations like this that broke with the new beta. The issue is in the inline color style attribute. 

Templates.Total += '# if(MV > 0) { # <td style="color:#cc7700;"> # } else if (MV < 0) { # <td style="color:#0055aa;"> # } else { # <td> # } #';

1 Answer, 1 is accepted

Sort by
2
Petyo
Telerik team
answered on 13 Oct 2011, 08:07 AM
Hello Patrick,

You can use double backslash ("\\") to escape hashes. In your case the template should look like this:

Templates.Total += '# if(MV > 0) { # <td style="color:\\#cc7700;"> # } else if (MV < 0) { # <td style="color:\\#0055aa;"> # } else { # <td> # } #';

We are working on providing user friendly error message in cases like that.

Best wishes,
Petyo
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
Patrick
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or