-
Notifications
You must be signed in to change notification settings - Fork 23
JSON is not loading #13
Comments
having the same issue. its's looking for the 'tplVars' at config.data.root +file + '.json' seems to work if you declare a variable in the grunt file for 'root' at the same level as 'dest' 'init' 'src' etc. as long as you're only using one root directory.. but for more complicated inheritance structures it could be tricky. |
ie swig: {
development: {
init: {
root: "struct/swig/",
allowErrors: true,
autoescape: true
},
dest: "www/",
root: "struct/swig/",
cwd: "struct/swig/",
src: ['**/*.swig'],
generateSitemap: false,
generateRobotstxt: true,
siteUrl: 'http://mydomain.net/',
production: false,
fb_appid: '1349v',
ga_account_id: 'UA-xxxxxxxx-1',
robots_directive: 'Disallow /',
sitemap_priorities: {
'_DEFAULT_': '0.5',
'index': '0.8',
'subpage': '0.7'
}
}
} |
awesome! thanks, pete! i had caught the same thing you did yesterday. thought i had tried it. the only thing i can think of is that i didn't restart grunt. ...and that would be a big ol' DOH! all is working now. thanks, again! |
Thanks for the details. We had refactor how the settings are stored. It looks like the right fix off hand is to just update the code to grab the root from the init object. I'm hoping to have some time this weekend to work on this a bit. |
For what its worth - It might be better to use the cwd to make the path instead of the init root. Since swig allows for an array of roots. (So you can have a templates folder or whatever in a separate dir) 2¢ |
Ah I can see exactly where this is an issue, and that it isnt covered by our test suite. I'll implement a quick fix shortly to restore the existing behavior, but I agree completely with @thisispete that it should handle multiple roots - though this could get tricky with multiple files with the same name ;) |
This has been fixed, and is released to npm as version 0.0.12 |
I have created an index.json file. This sits in the same directory as index.swig. When trying to load a property defined in index.json in index.swig, nothing happens. I have created a simple property called heading in my index.json file and am trying to load it by using:
in my swig file. Below is my swig config in Gruntfile.js and the index.json file i am loading.
swig config:
index.json
The page renders as expected. The only thing it is missing is the JSON variable. I am not sure if I am missing a step or if there is a bug. I am fairly new to grunt and swig. Thanks for any help/direction/assistance/slap-upside-the-head that can be given.
The text was updated successfully, but these errors were encountered: