Created
July 26, 2013 17:13
-
-
Save JofArnold/6090572 to your computer and use it in GitHub Desktop.
Snippet of Gruntfile.coffee code to wrap a number of json files and attach them to the namespace. Requires grunt-contrib-concat. More flexible than using some of the grunt json packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
concat: | |
json: | |
src: ['source/files/here.json'] | |
dest: 'output/files/here.js' | |
options: | |
banner: "(function(namespace){\n'use strict'\nnamespace.json={};\n" | |
footer: "\n})(YOURNAMESPACEHERE)" | |
process: (src,filepath) -> | |
arr = filepath.split '/' | |
filename = arr[arr.length-1] | |
# Process the filename here to extract bits you need. E.g.: | |
name = filename.replace('.json','') | |
return "namespace.json['#{name}']=#{src};\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment