pug-compiler.js 471 B

123456789101112131415161718
  1. var ensureRequire = require('../ensure-require.js')
  2. const throwError = require('../throw-error')
  3. module.exports = function (templatePart, config) {
  4. const options = (config && config['pug']) || {}
  5. if (templatePart.filename) {
  6. options.filename = templatePart.filename
  7. }
  8. var html
  9. ensureRequire('pug', 'pug')
  10. var jade = require('pug')
  11. try {
  12. html = jade.compile(templatePart.content, options)()
  13. } catch (err) {
  14. throwError(err)
  15. }
  16. return html
  17. }