rave-load-json

0.5.1 • Public • Published

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) { /* ... */ }

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.5.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.5.1
    0
  • 0.5.0
    1
  • 0.4.0
    1
  • 0.3.1
    1
  • 0.3.0
    1

Package Sidebar

Install

npm i rave-load-json

Weekly Downloads

4

Version

0.5.1

License

MIT

Last publish

Collaborators

  • unscriptable