How to use the consolidate.requires function in consolidate

To help you get started, we’ve selected a few consolidate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strapi / strapi / packages / strapi-middleware-views / lib / index.js View on Github external
_.forEach(opts.map, engine => {
          if (!consolidate.requires[engine]) {
            // Try to require them using `consolidate` or throw an error.
            try {
              consolidate.requires[engine] = require(path.resolve(
                strapi.config.appPath,
                'node_modules',
                engine
              ));
            } catch (err) {
              strapi.log.error(
                '`' + engine + '` template engine not installed.'
              );
              strapi.log.error(
                'Execute `$ npm install ' + engine + ' --save` to install it.'
              );
              process.exit(1);
            }
          }

          // Initialize the engine with `consolidate`.
github metalsmith / metalsmith-in-place / lib / index.js View on Github external
if (typeof opts === 'string') {
    opts = {engine: opts};
  }

  // An engine should be specified
  if (!opts.engine) {
    throw new Error('"engine" option required');
  }

  // Throw an error for unsupported engines or typos
  if (!consolidate[opts.engine]) {
    throw new Error('Unknown template engine: "' + opts.engine + '"');
  }

  if (typeof opts.exposeConsolidate === 'function') {
    opts.exposeConsolidate(consolidate.requires)
  }

  // Map options to local variables
  var engine = opts.engine;
  var partials = opts.partials;
  var pattern = opts.pattern;
  var rename = opts.rename;

  // Move all unrecognised options to params
  var params = omit(opts, settings);

  /**
   * Main plugin function
   */
  return function(files, metalsmith, done){
    var metadata = metalsmith.metadata();
github strapi / strapi / packages / strapi-middleware-views / lib / index.js View on Github external
_.forEach(opts.map, engine => {
          if (!consolidate.requires[engine]) {
            // Try to require them using `consolidate` or throw an error.
            try {
              consolidate.requires[engine] = require(path.resolve(
                strapi.config.appPath,
                'node_modules',
                engine
              ));
            } catch (err) {
              strapi.log.error(
                '`' + engine + '` template engine not installed.'
              );
              strapi.log.error(
                'Execute `$ npm install ' + engine + ' --save` to install it.'
              );
              process.exit(1);
            }
github tchapi / mlmmj-simple-web-interface / index.js View on Github external
// Consolidate, to make beautiful templates in nunjucks
var cons = require('consolidate')
  , nunjucks = require('nunjucks')

// Add mlmmj service wrapper module
var Mlmmj = require('./services/MlmmjWrapper')


var app = express()

/* Configuration is done here
*/
  // add nunjucks to requires so filters can be 
  // added and the same instance will be used inside the render method 
  cons.requires.nunjucks = nunjucks.configure(); 
  cons.requires.nunjucks.addGlobal('website_name', config.get('app').name);

  // Handy flash messages
  app.use(flash())

  // Use sessions
  app.use(session({ name: "mlmmj.web.session.id", secret: 'mlmmjNotSoSecretPhrase', cookie: { maxAge: null }, resave: true, saveUninitialized: true }))

  // Use passport-local auth system with persistent sessions
  app.use(passport.initialize())
  app.use(passport.session())

  // Static content
  app.use(express.static(__dirname + '/public'))

  // .. parse application/x-www-form-urlencoded
github coralproject / talk / src / core / server / app / index.ts View on Github external
function setupViews(options: AppOptions) {
  const { parent } = options;

  // Configure the default views directory.
  const views = path.join(__dirname, "views");
  parent.set("views", views);

  // Reconfigure nunjucks.
  (cons.requires as any).nunjucks = nunjucks.configure(views, {
    // In development, we should enable file watch mode, and prevent file
    // caching.
    watch: options.config.get("env") === "development",
    noCache: options.config.get("env") === "development",
  });

  // assign the nunjucks engine to .njk and .html files.
  parent.engine("html", cons.nunjucks);

  // set .html as the default extension.
  parent.set("view engine", "html");
}
github tchapi / mlmmj-simple-web-interface / index.js View on Github external
// Consolidate, to make beautiful templates in nunjucks
var cons = require('consolidate')
  , nunjucks = require('nunjucks')

// Add mlmmj service wrapper module
var Mlmmj = require('./services/MlmmjWrapper')


var app = express()

/* Configuration is done here
*/
  // add nunjucks to requires so filters can be 
  // added and the same instance will be used inside the render method 
  cons.requires.nunjucks = nunjucks.configure(); 
  cons.requires.nunjucks.addGlobal('website_name', config.get('app').name);

  // Handy flash messages
  app.use(flash())

  // Use sessions
  app.use(session({ name: "mlmmj.web.session.id", secret: 'mlmmjNotSoSecretPhrase', cookie: { maxAge: null }, resave: true, saveUninitialized: true }))

  // Use passport-local auth system with persistent sessions
  app.use(passport.initialize())
  app.use(passport.session())

  // Static content
  app.use(express.static(__dirname + '/public'))

  // .. parse application/x-www-form-urlencoded
  app.use(bodyParser.urlencoded({ extended: false }))
github forwardemail / email-templates / src / main.js View on Github external
et.render(locals, function (err, result) {
          result = result || {}
          next(err, result.html, result.text, result.subject, result.deeplink)
        })
      })
    }

    et.render(locals, function (err, result) {
      result = result || {}
      callback(err, result.html, result.text, result.subject, result.deeplink)
    })
  }
}

exportable.EmailTemplate = EmailTemplate
exportable.requires = require('consolidate').requires
module.exports = exportable
github zalando-incubator / hexo-theme-doc / lib / nodejs / swagger-to-html / core.js View on Github external
constructor (options) {
    this.options = Object.assign({
      input:(ctx) => Promise.resolve(ctx),
      render: consolidate.ejs,
      renderString: consolidate.requires.ejs.render,
      modules: {}
    }, options);
  }

consolidate

Modern and maintained fork of the template engine consolidation library. Maintained and supported by Forward Email <https://forwardemail.net>, the 100% open-source and privacy-focused email service.

MIT
Latest version published 5 months ago

Package Health Score

81 / 100
Full package analysis