Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON with : character cannot be used in the template #118

Open
kathryn-thompson opened this issue Jun 16, 2011 · 2 comments
Open

JSON with : character cannot be used in the template #118

kathryn-thompson opened this issue Jun 16, 2011 · 2 comments

Comments

@kathryn-thompson
Copy link

I have the following template:

<script id="SearchResultsTemplate" type="text/x-jquery-tmpl">
{{each Hits}}
    Page ${PAGENUMBER} - ${autn:summary} 
{{/each}}
</script>'

I can pull PAGENUMBER out of the JSON but not autn:summary (it complains about the : tag presumably)

How can i escape it? I've tried : and ; and \3A but nothing works.

Thanks

Gordon

@patridge
Copy link

That may be a symptom of the fact that a colon (":") isn't valid character in a JavaScript name. I won't comment on whether the colon should be used or not, but, in this case you can work around that limitation with object array notation: ${prop[autn:summary]}. It will take a tiny bit of tweaking on your {{each}}, but here is a stripped-down sample jsFiddle.

@rdworth
Copy link
Contributor

rdworth commented Oct 8, 2011

Thanks for taking the time to submit this issue. Just wanted to let you know this plugin is no longer being actively developed or maintained by the jQuery team. See README for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants