for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
/**
* @author Donii Sergii <[email protected]>
*/
const Handlebars = require('handlebars')
const fs = require('fs')
const path = require('path')
const beautify = require('js-beautify').js_beautify
const apiTemplate = fs.readFileSync(path.join(__dirname, '/../../../js-template/api.hbs'), 'utf-8')
const methods = fs.readFileSync(path.join(__dirname, '/../../../js-template/methods.hbs'), 'utf-8')
const method = fs.readFileSync(path.join(__dirname, '/../../../js-template/method.hbs'), 'utf-8')
Handlebars.registerPartial('methods', methods)
Handlebars.registerPartial('method', method)
Handlebars.registerHelper('toLowerCase', function (word) {
return word.toLowerCase()
})
Handlebars.registerHelper('brackets', function (word) {
return `{${word}}`
module.exports = function (data) {
let template = Handlebars.compile(apiTemplate)(data)
template = beautify(template, {indent_size: 2, max_preserve_newlines: -1})
return template
}