RAML Generator
Generate files from a RAML document and Handlebars templates.
Installation
npm install raml-generator --save
Usage
The module accepts a map of Handlebars templates, partials and helpers, and exports a function that can be used to generate files from a RAML object and user data.
JavaScript Usage
Create the generator function from an object specification. The returned object accepts two parameters, the RAML object and user package information.
var fs = require('fs')
var generator = require('raml-generator')
var generate = generator({
templates: {
'index.js': fs.readFileSync(__dirname + '/templates/index.js.hbs', 'utf8')
},
helpers: {
stringify: require('javascript-stringify')
}
})
Handlebars
Inside the Handlebars templates, the RAML interface is exposed as Handlebars data.
var baseUri = {{stringify baseUri}}
The user data is automatically provided as the Handlebars compile context.
Bin Script
A bin
script is provided for you to use with your custom generator. Just require raml-generator/bin
and pass in the generator function (from above), package information (package.json
) and process.argv
.
var bin = require('raml-generator/bin')
var generate =
bin(generate, require('./package.json'), process.argv)
License
Apache License 2.0