#!/usr/bin/env node 'use strict'; /* Example of using raml2html as a script. Run this as `node script.js` */ const raml2html = require('..'); const path = require('path'); const ramlFile = path.join(__dirname, 'helloworld.raml'); /** * Using the default templates. * * raml2html.render() needs a config object with at least a `processRamlObj` property. * Instead of creating this config object ourselves, we can just ask for raml2html.getDefaultConfig(): */ const config1 = raml2html.getConfigForTheme('raml2html-default-theme'); raml2html.render(ramlFile, config1).then( result => { console.log('1: ', result.length); }, error => { console.log('error! ', error); } ); /** * Using your own templates using the default processRamlObj function. */ const config2 = raml2html.getConfigForTemplate( './custom-template-test/template.nunjucks' ); raml2html.render(ramlFile, config2).then( result => { console.log('2: ', result.trim().length); }, error => { console.log('error! ', error); } ); /** * If you want to customize everything, just create the config object yourself from scratch. * * The important thing is to have a processRamlObj property: a function that takes a raw RAML object and returns * a promise with the finished output */ const config3 = { processRamlObj() { return new Promise(resolve => { resolve('