Discussion:
Issue 65 in json-template: Javascript within JSON templates
j***@public.gmane.org
2011-09-03 03:54:36 UTC
Permalink
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 65 by ewan.duc...-***@public.gmane.org: Javascript within JSON templates
http://code.google.com/p/json-template/issues/detail?id=65

What steps will reproduce the problem?
1. I have a template var index = jsontemplate.Template("<script
type="text/javascript">function
test(){alert('test')}</script><h2>{title}</h2>");
2. When loading the template the error "Uncaught SyntaxError: Unexpected
identifier" is shown.

What is the expected output? What do you see instead? Should not error and
have the function call test() available to call on the page. Instead it
errors out due to the open braces in javascript "{". I have tried to use
\u007B with the same result.

What version of the product are you using? On what operating system?
Windows 7,
Chrome 13.0.782.218,
json-template-0.8
jquery 1.5.1

Please provide any additional information below.
--
You received this message because you are subscribed to the Google Groups "JSON Template" group.
To post to this group, send email to json-template-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to json-template+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/json-template?hl=en.
j***@public.gmane.org
2011-11-15 07:35:39 UTC
Permalink
Updates:
Status: Done

Comment #1 on issue 65 by andyc...-***@public.gmane.org: Javascript within JSON
templates
http://code.google.com/p/json-template/issues/detail?id=65

Sorry for the very late response -- there are a couple solutions:

1. Use {{}} or [] as your template delimiters. (the "meta" option to the
constructor)

2. If you split your JavaScript over multiple lines so that { and } don't
appear on the same line it will parse.

3. Escape the {}. {.meta-left} and {.meta-right} are { and }.
--
You received this message because you are subscribed to the Google Groups "JSON Template" group.
To post to this group, send email to json-template-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to json-template+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/json-template?hl=en.
Loading...