m90/require-yaml

require.js loader plugin for YAML files

★ 2Forks 1JavaScriptGitHub ↗Compare

README

require-yaml

Build Status

a transform for loading YAML files in requirejs, using js-yaml

Install the plugin and its dependencies using bower

$ bower install require-yaml --save

If you prefer a manual install, make sure to satisfy the js-yaml and text dependencies.

Simple usage

First, make sure the module names js-yaml and text resolve to the proper locations (both are installed alongside the loader when you are using bower):

requirejs.config({
    paths : {
        'yaml' : './bower_components/require-yaml/yaml',
        'js-yaml' : './bower_components/js-yaml/dist/js-yaml',
        'text' : './bower_components/requirejs-text/text'
    }
});

Now you're ready to require YAML as plain JavaScript objects:

require('yaml!some/folder/somefile.yaml', function(data){
    console.log(data); // => logs the transformed object
});

For more information see the js-yaml repository.

Build time

On build time you can simply use stubModules in your build config to get rid of the parser in the file you ship to production:

({
    stubModules: ['text','js-yaml','yaml']
})

##License MIT © Frederik Ring

Contributors

m90

Issues