Pug template engine plugin for diet based on pug. Support for sending data to view through $.data.PARAM
and displayed via #{PARAM}
.
Learn how to use it at the engine's website:
- Website: http://pug-lang.com/
npm install diet-pug
index.js
// Require Diet server
var server = require('diet')
// Require diet-pug plugin
var pug = require('diet-pug')({path: app.path + '/static/pug/'})
// Instantiate server
var app = server()
// Set server listening port
app.listen('http://localhost:8000')
// Assign pug plugin to the header
app.header(pug)
// Create a route
app.get('/', function($) {
// Render pug file! this will render ./yourConfiguredDirectory/index.pug
$.data.message = 'This is awesome!'
$.render('index')
})
app.get('/profile', function ($) {
// Render pug file! this will render ./.../yourConfiguredDirectory/profile.pug
$.render('profile')
})
~/.../static/pug/index.pug
p Received message: #{message}
$.render('yourFile') // will serve yourConfiguredDirectory/yourFile.pug
$.render('yourFile.pug') //wil serve yourConfiguredDirectory/yourFile.pug
Please refer to The License.