yamler

1.0.1 • Public • Published

Yamler

A yaml parser for javascript that renders variables.

Installation

Install using npm:

$ npm install --save yamler

Import yamler and give it the file to render:

var yamler = require('yamler');
var file = yamler('file.yaml');

Example

This sample yaml file:

sample:
  variable: {{ process.env._ }}

Will be turned into this javascript object:

{ 
    test: { 
        variable: '/Users/mateusnroll/.nvm/versions/node/v6.7.0/bin/node' 
    } 
}

Dependencies

js-yaml The official PyYAML port for Javascript. Used to parse the yaml file into a javascript object.

Handlebars Templating language to parse the variables inside the yaml file.

API

yamler(filePath, [safe], [context])

  • filePath (default: null) - String with the path to the file. Will be read using fs.readFilySync()
  • safe (default: false) - Boolean to choose if you want to do a safe content load. If you do not trust or control the contents of the yml file, use true.
  • context (default: global) - Where to look for variables. If left blank, will attach node's global scope.

License

Yamler is released under the MIT license

Package Sidebar

Install

npm i yamler

Weekly Downloads

4

Version

1.0.1

License

MIT

Last publish

Collaborators

  • mateusnroll