How to use the consolidate.swig 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 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 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 AVGP / cloud9hub / server.js View on Github external
// Load configurations
// Set the node enviornment variable if not set before
process.env.NODE_ENV = process.env.NODE_ENV || 'development';

var app = express();

app.set('showStackError', true);
// cache=memory or swig dies in NODE_ENV=production
app.locals.cache = 'memory';
// Prettify HTML
app.locals.pretty = true;

app.set('nextFreeWorkspacePort', 5000);

app.engine('html', consolidate.swig);

// Start the app by listening on 
var port = process.env.PORT || 3105;

// all environments
app.set('port', port);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.set('baseUrl', config.BASE_URL);
app.set('runningWorkspaces', {});

//Auth
passport.use(new GithubStrategy({
    clientID: config.GITHUB_CLIENT_ID,
    clientSecret: config.GITHUB_CLIENT_SECRET,
    callbackURL: app.get('baseUrl') + ':' + app.get('port') + '/auth/github/callback'
github jonschlinkert / template / test / template.render.cached.js View on Github external
it('should use the key of a cached template to determine the consolidate engine to use:', function (done) {
      template.engine('hbs', consolidate.handlebars);
      template.engine('swig', consolidate.swig);
      template.engine('tmpl', consolidate.lodash);

      template.page('a.hbs', {content: '<title>{{title}}</title>', title: 'Handlebars'});
      template.page('b.tmpl', {content: '<title>&lt;%= title %&gt;</title>', title: 'Lo-Dash'});
      template.page('d.swig', {content: '<title>{{title}}</title>', title: 'Swig'});

      Object.keys(template.views.pages).forEach(function(name) {
        var ext = path.extname(name);

        template.render(name, function (err, content) {
          if (err) console.log(err);

          if (ext === '.hbs') {
            content.should.equal('<title>Handlebars</title>');
          }
          if (ext === '.tmpl') {
github popomore / social-share / examples / server.js View on Github external
var express = require('express');
var engines = require('consolidate');
var swig = require('swig');
var parser = require('../src/parser');

var app = express();
app.engine('html', engines.swig);
app.set('view engine', 'html');
swig.init({
    root: __dirname,
    allowErrors: true,
    cache: false
});
app.set('views', __dirname);
app.set("view options", {layout: false});

app.get('/', function(req, res) {
  res.render('server.html');
});

app.get('/redirect', function(req, res) {
    var url = parser(req.query.service, req.query);
    res.redirect(url);
github chovy / express-template-demo / demo / app.js View on Github external
var app = express();

if (template_engine == 'dust') {
    var dust = require('dustjs-linkedin'),
        cons = require('consolidate');

    app.engine('dust', cons.dust);

} else if (template_engine == 'ejs') {
    app.engine('ejs', engine);
} else if (template_engine == 'swig') {
    var swig = require('swig'),
        cons = require('consolidate');

    app.engine('swig', cons.swig);
    //app.set('view engine', 'html');
}

app.configure(function() {

    if (template_engine == 'swig') {
        app.set('view engine', 'swig');
        app.set('view options', {
            layout: false
        });
    }

    app.set('template_engine', template_engine);
    app.set('domain', domain);
    app.set('port', process.env.PORT || 8080);
    app.set('views', __dirname + '/views');
github dchester / showcase / index.js View on Github external
app.configure(function(){
		app.engine('.html', consolidate.swig);
		app.set('router', router);
		app.set('view engine', 'html');
		app.set('views', views);
		app.set('port', process.env.PORT || config.port || 3000);
		app.use(middleware.errorHandler);
		app.use(express.static(path.join(__dirname, 'public')), { maxAge: 600 });
		app.use(express.static(storagePath));
		app.use(express.favicon());
		app.use(express.logger('dev'));
		app.use(express.bodyParser());
		app.use(express.methodOverride());
		app.use(express.cookieParser('__SECRET__'));
		app.use('/files', express.cookieSession({ secret: secret }));
		app.use('/workspaces', express.cookieSession({ secret: secret }));
		app.use('/admin', express.cookieSession({ secret: secret }));
		app.use(flash());
github weareopensource / Node / lib / services / express.js View on Github external
module.exports.setEngine = (app) => {
  app.engine('html', cons.swig);
  app.set('view engine', 'html');
  app.set('views', path.resolve('modules/users/templates'));
};

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