Skip to content

Instantly share code, notes, and snippets.

@tastywheat
Last active August 29, 2015 13:56
Show Gist options
  • Save tastywheat/8809434 to your computer and use it in GitHub Desktop.
Save tastywheat/8809434 to your computer and use it in GitHub Desktop.
express-consolidate-template.js
var express = require('express')
, cons = require('consolidate')
, app = express();
// assign the swig engine to .html files
app.engine('html', cons.swig);
// set .html as the default extension
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.get('/', function(req, res){
res.render('index', {
memory: true,
title: 'Consolidate.js',
name: 'brian'
});
});
app.listen(3000);
console.log('Express server listening on port 3000');
/*
<html>
<head></head>
<body>
<script>
alert('{{name}}');
</script>
</body>
</html>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment