I've been going through coffeescript documentation and stackoverflow to find answer for my question to no avail.
I have a javascript file containing just one literal object compiled from coffeescript.
products =
1:
name: 'foo'
id: 1
description: 'lorem ipsum dolor sit'
youtube: 'path
2:
name: 'bar'
id: 2
description: 'lorem ipsum dolor sit'
youtube: 'path
but what I'm getting back is:
(function() {
return products = {
1: {
name: 'foo lama',
id: 1,
...
I'm loading that file as a resource through ajax and I'm not able to use it as a proper JSON.
Is there a way to prevent coffeescript from wrapping the code into immediately invoked function or (and that'd be the best solution) is there a way to compile only JSON object without naming it?
Thanks
Copyright Notice:Content Author:「MelkorNemesis」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/15551331/prevent-coffeescript-from-wrapping-code-into-immediately-invoked-function