How to use consolidate - 10 common examples

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 jonschlinkert / template / test / helpers.js View on Github external
'use strict';

/* deps: mocha swig */
var assert = require('assert');
var should = require('should');
var async = require('async');
var matter = require('parser-front-matter');
var consolidate = require('consolidate');
var handlebars = require('engine-handlebars');
var lodash = consolidate.lodash;
var swig = consolidate.swig;

var App = require('..');
var app;

describe('sync helpers', function () {
  beforeEach(function () {
    app = new App();
    app.engine('tmpl', require('engine-lodash'));
    app.create('page');
  })

  it('should register a helper:', function () {
    app.helper('a', function () {});
    app.helper('b', function () {});
    app._.helpers.sync.should.have.property('a');
    app._.helpers.sync.should.have.property('b');
github shmoop207 / appolo / test / mock / config / middlewares / all.js View on Github external
module.exports = function (app, env) {
    app.use(bodyParser.urlencoded({
        extended: true,
        parameterLimit: 10000,
        limit: 1024 * 1024 * 10
    }));
    app.use(bodyParser.json({
        //parameterLimit: 10000,
        limit: 1024 * 1024 * 10
    }));
    app.viewEngine(consolidate.nunjucks);
    app.use(cookieParser());
    app.use(serve(path.join(__dirname, "../../uploads")));
    app.use(function (req, res, next) {
        res.setHeader("Access-Control-Allow-Origin", req.headers.origin || '*');
        res.setHeader("Access-Control-Allow-Credentials", "true");
        res.setHeader("Cache-Control", "max-age=0, no-cache, must-revalidate, proxy-revalidate");
        res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
        res.setHeader("P3P", 'CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
        res.setHeader("Access-Control-Allow-Methods", "GET, PUT, PATCH, DELETE, HEAD, OPTIONS");
        res.setHeader("Allow", "GET, PUT, PATCH, DELETE, HEAD, OPTIONS");
        //
        // intercept OPTIONS method
        if (req.method == 'OPTIONS') {
            res.setHeader('Content-Length', '0');
            res.statusCode = 204;
            res.end();
github emblicaorg / airfield / airfield.js View on Github external
app.configure(function(){
  app.set('port', process.env.PORT || settings.port);
  app.set('views', __dirname + '/views');
  console.log(__dirname);
  app.engine('.html', cons.swig);
  app.set('view engine', 'html');
  swig.init({
	root: __dirname + '/views',
	allowError: true	
  }); 
// app.set('view options', layout: false);
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser(settings.cookieSecret));
  app.use(express.session({
	secret: settings.sessionSecret,
	store: new RedisStore
}));
  app.use(app.router);
github itstrive / striveCode / hi-wiki-demo / express / demo9-consolidate / server.js View on Github external
const consolidate = require('consolidate');

/* 
//ejs调用
app.engine('ejs', consolidate.ejs);
app.set('views','views');
app.set('view engine', 'ejs');
*/

//jade
/* app.engine('jade', consolidate.jade);  //第一个参数为模板文件 后缀
app.set('views','views');
app.set('view engine', 'jade'); */

//swig
app.engine('swig', consolidate.swig); //以 swig结尾的模板,其实swig是以html结尾的
app.set('views','views');
app.set('view engine', 'swig');

app.get('/',(req,res)=>{
	res.render('index',{title:'Strive',arr:['apple','banana','orange','tomato']});
});

app.use(express.static('www'));

let server = app.listen(3000, function () {
	let host = server.address().address;
	let port = server.address().port;

	console.log('服务器起启动 在 http://%s%s', host, port);
});
github sdelements / lets-chat / app / server.js View on Github external
}, 
            secret: self.config.cookie_secret,
            store: self.sessionStore
        }));

        // Auth
        self.app.use(passport.initialize());
        self.app.use(passport.session());

        // Templates
        swig.init({
            cache: !self.config.debug,
            root: 'templates',
            allowErrors: self.config.debug
        });
        self.app.engine('.html', cons.swig);
        self.app.set('view engine', 'html');
        self.app.set('views', 'templates');

        // Static
        self.app.use('/media', express.static(path.resolve('media')));

        // Router
        self.app.use(self.app.router);

    });
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 wesleytodd / nighthawk / example / react / index.js View on Github external
require('babel-register')
var app = require('express')()
var serveStatic = require('serve-static')
var ejs = require('consolidate').ejs
var routes = require('./routes')

app.engine('html', ejs)
app.set('view engine', 'html')
app.set('views', '.')

// Register routes
routes(app)

// Serve static assets
app.use('/static', serveStatic('.'))

// Start server
app.listen('1234', function () {
  console.log('Listening on 1234')
})
github wesleytodd / nighthawk / example / basic / server.js View on Github external
var app = require('express')();
var serveStatic = require('serve-static');
var ejs = require('consolidate').ejs;
var routes = require('./routes');

app.engine('html', ejs);
app.set('view engine', 'html');
app.set('views', 'templates');

// Register routes on child app
routes(app);

// Serve static assets on base app
app.use('/static', serveStatic('.'));

// Start server
app.listen('1234', function () {
	console.log('Listening on 1234');
});

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