$ npm install pug
==== Command Line ====
After installing the latest version of [[http://nodejs.org/|Node.js]], install with:
$ npm install pug-cli -g
and run with
$ pug --help
===== Syntax =====
Pug is a clean, whitespace sensitive syntax for writing html. Here is a simple example:
doctype html
html(lang="en")
head
title= pageTitle
script(type='text/javascript').
if (foo) bar(1 + 5)
body
h1 Pug - node template engine
#container.col
if youAreUsingPug
p You are amazing
else
p Get on it!
p.
Pug is a terse and simple templating language with a
strong focus on performance and powerful features.
becomes
Pug
Pug - node template engine
You are amazing
Pug is a terse and simple templating language with a strong focus on performance and powerful features.
===== API =====
For full API, see [[https://pugjs.org/api/reference.html|pugjs.org/api/reference.html]]
var pug = require('pug');
// compile
var fn = pug.compile('string of pug', options);
var html = fn(locals);
// render
var html = pug.render('string of pug', merge(options, locals));
// renderFile
var html = pug.renderFile('filename.pug', merge(options, locals));
==== Options ====
* ''filename'' Used in exceptions, and required when using includes
* ''compileDebug'' When ''false'' no debug instrumentation is compiled
* ''pretty'' Add pretty-indentation whitespace to output (false by default)
===== Browser Support =====
The latest version of pug can be download for the browser in standalone form from [[https://pugjs.org/js/pug.js|here]]. It only supports the very latest browsers though, and is a large file. It is recommended that you pre-compile your pug templates to JavaScript.
To compile a template for use on the client using the command line, do:
$ pug --client --no-debug filename.pug
which will produce ''filename.js'' containing the compiled template.
===== Additional Resources =====
Tutorials:
* cssdeck interactive [[http://cssdeck.com/labs/learning-the-jade-templating-engine-syntax|Pug syntax tutorial]]
* cssdeck interactive [[http://cssdeck.com/labs/jade-templating-tutorial-codecast-part-2|Pug logic tutorial]]
* [[https://gist.github.com/japboy/5402844|Pug について。]] (A Japanese Tutorial)
Implementations in other languages:
* [[https://github.com/acidjazz/larpug|Larpug - Pug for Laravel]]
* [[https://github.com/pug-php/pug|php]]
* [[https://scalate.github.io/scalate/documentation/scaml-reference.html|scala]]
* [[https://github.com/slim-template/slim|ruby]]
* [[https://github.com/SyrusAkbary/pyjade|python]]
* [[https://github.com/neuland/jade4j|java]]
Other:
* [[https://github.com/brianc/jade-mode|Emacs Mode]]
* [[https://github.com/digitaltoad/vim-pug|Vim Syntax]]
* [[http://github.com/miksago/jade-tmbundle|TextMate Bundle]]
* [[https://github.com/aaronmccall/jade.mode|Coda/SubEtha syntax Mode]]
* [[https://github.com/donpark/html2jade|html2pug]] converter
* [[https://github.com/SE7ENSKY/jade2php|pug2php]] converter
* [[https://github.com/ded/jade-server|Pug Server]] Ideal for building local prototypes apart from any application
* [[https://github.com/yivo/pug-ruby|pug-ruby]] gem: Allows to invoke Pug and Jade from Ruby
* [[https://github.com/yivo/pug-rails|pug-rails]] gem: Integrates Pug and Jade into your Rails application
===== License =====
MIT