How to use consolidate.swig:
405 406 407 408 409 410 411 412 413 414
var jsonParam = msg; try { console.log('Swig : ' + JSON.stringify(jsonParam)); cons.swig(emailEventJson.template, jsonParam.data) .then(function (html) { console.log(html); sendEmail(emailEventJson, html); })
How to use consolidate.lodash:
0 1 2 3 4 5 6 7 8 9
'use strict'; var path = require('path'); var consolidate = require('consolidate'); consolidate.requires.lodash = require('lodash'); var tmpl = consolidate.lodash; var BPromise = require('bluebird'); var utils = require('./utils'); var render = function render(template, datas, callback) {
How to use consolidate.handlebars:
GitHub: UXFoundry/hashdo
80 81 82 83 84 85 86 87 88 89
if (footer) { viewModel.partials.footer = getRelativePartial(footer); } Consolidate.handlebars(Path.join(hbTemplatePath, 'card.hbs'), viewModel, function (err, html) { if (!err) { callback && callback(html); } else {
How to use consolidate.js:
13 14 15 16 17 18 19 20 21 22
```js assemble.engine('hbs', require('engine-handlebars')); ``` ### consolidate.js [consolidate.js] normalizes the APIs for the most common node.js template engines. Here is how to register an engine using consolidate: **Install with npm**
291
0
2
See more examples
How to use consolidate.clearCache:
GitHub: ASQ-USI/ASQ
143 144 145 146 147 148 149 150 151 152
// HACK: empty dust cache // if multiple servers are used then the rest of the servers WILL NOT // get notified :-( // TODO: should only delete the updated presentation path cons.clearCache() logger.log({ owner_id: req.user._id, slideshow: slideshow._id,
10
28
12
See more examples
How to use consolidate.jade:
GitHub: UXFoundry/hashdo
24 25 26 27 28 29 30 31 32 33
if (jadeFile) { // Handle exports. viewModel.basedir = Path.join(__dirname, '../templates/jade/'); Consolidate.jade(jadeFile, viewModel, function (err, html) { if (!err) { callback && callback(html); } else {
How to use consolidate.dust:
GitHub: toyblocks/toyblocks
4 5 6 7 8 9 10 11 12 13
var express = require('express'); var http = require('http'); //var https = require('https'); var path = require('path'); var cons = require('consolidate'); var dust = cons.dust; var mongodb = require('mongodb'); var jobs = require('./jobs'); var logger = require('morgan'); var methodOverride = require('method-override');
How to use consolidate.requires:
GitHub: doowb/octobox.js
15 16 17 18 19 20 21 22 23
app.enable('trust proxy'); app.set('url', config.url || 'http://localhost:3000'); app.set('root_path', '/'); // view engine setup app.set('handlebars', consolidate.requires.handlebars); app.engine('hbs', consolidate.handlebars); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'hbs');
How to use consolidate.ejs:
360 361 362 363 364 365 366 367 368 369
// req.query("INSERT INTO Login (Username, HashedPassword, StudentID, Faculty_ID, GuestID) VALUES (@username, @hashedPassword, @studentId, @facultyId, @guestId)").then(function(recordset) { console.log("Query: " + squery); req.query(squery).then(function(recordset) { console.log("New " + mode + " login entry inserted into database."); if(mode === 'guest') { cons.ejs('./AdminUI/AdminUI-Entry/GuestEntry.html',{uname: Username}, function(err, html){ if(err) { console.error('Error templating with EJS'); throw err; }
How to use consolidate.render:
GitHub: aosqy/asqy-cli
194 195 196 197 198 199 200 201 202 203
// 文件是.js或者.json才是模板引擎 if (file.includes('.js') || file.includes('.json')) { let content = files[file].contents.toString(); //文件内容 // 我们将ejs模板引擎的内容找到 才编译 if (content.includes('<%')) { content = await render(content, res); files[file].contents = Buffer.from(content); //渲染 } } })