Skip to content

Instantly share code, notes, and snippets.

@JofArnold
Created July 26, 2013 17:13
Show Gist options
  • Save JofArnold/6090572 to your computer and use it in GitHub Desktop.
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
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