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/'); | |
| }); |