Last active
August 29, 2015 14:07
-
-
Save itsthatguy/edc6a9815bba68e15d04 to your computer and use it in GitHub Desktop.
Browserify + NPM + Rails config variables cleanly shared with javascript
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
| dm = require('lib/data_manager') | |
| config = dm.load('data/with.json') |
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
| { | |
| "application": { | |
| "name": "<%= AppConfig.Application.brand %>" | |
| } | |
| } |
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
| 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