Skip to content

Instantly share code, notes, and snippets.

@pateketrueke
Created July 9, 2016 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pateketrueke/f4d1c407963930e9ab1ea4081fd7cdce to your computer and use it in GitHub Desktop.
Save pateketrueke/f4d1c407963930e9ab1ea4081fd7cdce to your computer and use it in GitHub Desktop.
Tarima + Express

Write the following view-script:

src/example.js.hbs.pug

h1 {{value}}

Execute npm start.

{
"name": "tarima-express",
"scripts": {
"build": "tarima -fdV",
"start": "node server.js",
"prestart": "npm run build"
},
"tarima": {
"rename": [
"**/*.js:views/{filepath/1}/{filename}.{extname}"
]
},
"dependencies": {
"express": "^4.14.0",
"handlebars": "^4.0.5",
"pug": "^2.0.0-beta3",
"tarima-cli": "^0.1.8"
}
}
var express = require('express'),
app = express();
app.engine('js', function (path, options, callback) {
var tpl = require(path);
callback(null, tpl(options));
});
app.set('view engine', 'js');
app.set('views', ['build/views']);
app.get('/', function (req, res) {
res.render('example', {
value: 'OSOM'
});
});
app.listen(5050, function () {
console.log('Listening at http://localhost:5050/');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment