Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 20 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | /** |
||
4 | const Handlebars = require('handlebars') |
||
5 | const fs = require('fs') |
||
6 | const path = require('path') |
||
7 | const beautify = require('js-beautify').js_beautify |
||
8 | const apiTemplate = fs.readFileSync(path.join(__dirname, '/../../../js-template/api.hbs'), 'utf-8') |
||
9 | const methods = fs.readFileSync(path.join(__dirname, '/../../../js-template/methods.hbs'), 'utf-8') |
||
10 | const method = fs.readFileSync(path.join(__dirname, '/../../../js-template/method.hbs'), 'utf-8') |
||
11 | Handlebars.registerPartial('methods', methods) |
||
12 | Handlebars.registerPartial('method', method) |
||
13 | Handlebars.registerHelper('toLowerCase', function (word) { |
||
14 | return word.toLowerCase() |
||
15 | }) |
||
16 | Handlebars.registerHelper('brackets', function (word) { |
||
17 | return `{${word}}` |
||
18 | }) |
||
19 | module.exports = function (data) { |
||
20 | let template = Handlebars.compile(apiTemplate)(data) |
||
21 | template = beautify(template, {indent_size: 2, max_preserve_newlines: -1}) |
||
22 | return template |
||
23 | } |