Skip to content

Instantly share code, notes, and snippets.

@itsthatguy
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save itsthatguy/edc6a9815bba68e15d04 to your computer and use it in GitHub Desktop.

Select an option

Save itsthatguy/edc6a9815bba68e15d04 to your computer and use it in GitHub Desktop.
Browserify + NPM + Rails config variables cleanly shared with javascript
dm = require('lib/data_manager')
config = dm.load('data/with.json')
{
"application": {
"name": "<%= AppConfig.Application.brand %>"
}
}
path = require('path')
class DataManager
@load: (file, name) ->
responseData = null
cleanPath = path.normalize(file)
$.ajax({
url: path.join('/assets', cleanPath)
async: false
dataType: 'json'
}).done (data) => responseData = data
return responseData
module.exports = DataManager
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment