/diet-pug

Jade template engine plugin for diet.js

Primary LanguageJavaScriptMIT LicenseMIT

diet-pug

Pug template engine plugin for diet based on pug. Support for sending data to view through $.data.PARAM and displayed via #{PARAM}.

Learn about pug:

Learn how to use it at the engine's website:

Install

npm install diet-pug

NPM

Example Usage

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}

File Rendering

$.render('yourFile') // will serve yourConfiguredDirectory/yourFile.pug

$.render('yourFile.pug') //wil serve yourConfiguredDirectory/yourFile.pug

License

Please refer to The License.