renderer.js 391 B

12345678910111213141516171819
  1. const _ = require('lodash')
  2. const cheerio = require('cheerio')
  3. module.exports = {
  4. async render() {
  5. const $ = cheerio.load(this.input)
  6. if ($.root().children().length < 1) {
  7. return ''
  8. }
  9. for (let child of this.children) {
  10. const renderer = require(`../${_.kebabCase(child.key)}/renderer.js`)
  11. renderer.init($, child.config)
  12. }
  13. return $.html()
  14. }
  15. }