rave-load-json
v0.5.1
Published
Adds json loading to RaveJS based on file extensions.
Downloads
13
Maintainers
Readme
rave-load-json
Adds json loading to rave.js based on file extensions.
By default, rave-load-json loads json when it detects a '.json' file extension.
You can change this list by adding a loadJson
rave env property.
For example, to detect ".json" and ".config"
extensions, add the following to your app's bower.json or package.json:
{
"rave": {
"env": {
"loadJson": {
"extensions": [ "json", "config" ]
}
}
}
}
Usage
Importing a json file as a module is easy. Just import it as if it were a JavaScript module.
For CommonJS/node-formatted modules (or AMD-wrapped CommonJS):
var config = require('./config.json');
// ...
if (config.isMobile) { /* ... */ }
For classic AMD modules:
define(['./config.json'], function (config) {
// ...
if (config.isMobile) { /* ... */ }
});
For ES6-formatted modules:
import config from './config.json';
// ...
if (config.isMobile) { /* ... */ }