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

Syntax Error while processing template

2 Answers 418 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 21 Nov 2011, 02:35 AM
I have a really simple template that causes a syntax error with kendo templates in Google Chrome. I'm using Kendo beta2 and jQuery 1.6.4. Here's the template:

This is broken:
<script type="text/x-kendo-template" id="test">
    # length = "abc".length #
    #= length #
</script>

This works:
<script type="text/x-kendo-template" id="test">
    #= length = "abc".length #
</script>


Notice that's the exact same line, except with and without the = sign.  The error that it gives is this:

  1. Uncaught SyntaxError: Unexpected identifier
    1. jQuery.extend.proxy.proxyjquery-1.6.4.js:814
    2. (anonymous function)fiddle.jshell.net:40
    3. jQuery.event.handlejquery-1.6.4.js:3001
    4. jQuery.event.add.elemData.handle.eventHandle

If you want to see for yourself, here's the jsfiddle

Notice nothing is displayed, and there's an error in the javascript console.

It seems like variable assignment in a non-printing # block is breaking the parser. Any thoughts?

2 Answers, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 21 Nov 2011, 04:19 AM
It seems that # # blocks require a semicolon for new variable declarations, i.e.

# foo = 3; #

However, #= # blocks can't have a semicolon, otherwise they throw an Unexpected Token ;, i.e.

#= foo = 3 #

Seems like this is a bug, but the semicolon workaround works for now.
0
Petyo
Telerik team
answered on 01 Dec 2011, 10:32 AM
Hi Tim,

Just wanted to let you know that this problem is resolved with the new release. Semicolons are no longer needed. I made a small jsFiddle example to demonstrate it.

Kind regards,
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
Tim
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Petyo
Telerik team
Share this question
or