1<!-- Coppied from root directory --> 2 3<a href="https://pugjs.org"><img src="https://cdn.rawgit.com/pugjs/pug-logo/eec436cee8fd9d1726d7839cbe99d1f694692c0c/SVG/pug-final-logo-_-colour-128.svg" height="200" align="right"></a> 4# Pug 5 6Full documentation is at [pugjs.org](https://pugjs.org/) 7 8 Pug is a high performance template engine heavily influenced by [Haml](http://haml.info/) 9 and implemented with JavaScript for [Node.js](http://nodejs.org) and browsers. For bug reports, 10 feature requests and questions, [open an issue](https://github.com/pugjs/pug/issues/new). 11 For discussion join the [chat room](https://gitter.im/pugjs/pug). 12 13 You can test drive Pug online [here](https://pugjs.org/). 14 15 [](https://travis-ci.org/pugjs/pug) 16 [](https://coveralls.io/r/pugjs/pug?branch=master) 17 [](https://david-dm.org/pugjs/pug?path=packages/pug) 18 [](https://david-dm.org/pugjs/pug?path=packages/pug&type=dev) 19 [](https://www.npmjs.com/package/pug) 20 [](https://gitter.im/pugjs/pug?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 21 22## Rename from "Jade" 23 24This project was formerly known as "Jade." However, it has been revealed to us that "Jade" is a registered trademark, and as a result a rename is needed. After some discussion among the maintainers, **"Pug"** has been chosen as the new name for this project. The next major version will carry "pug" as the package name. 25 26If your package or app currently uses `jade`, don't worry: we have secured permissions to continue to occupy that package name, although all new versions will be released under `pug`. 27 28Before the renaming, we had already begun working on an incompatible Jade 2.0.0. We have then made it so that this new major version bump will coincide with the rename to Pug. Therefore, upgrading from Jade to Pug will be the same process as upgrading any other package with a major version bump. Currently, Pug 2.0.0 is still under beta stage, and there are several syntactic differences we have deprecated and removed. Such differences are documented at [#2305](https://github.com/pugjs/pug/issues/2305). 29 30The website and documentation for Pug are still being updated, but if you are new to Pug, you should get started with the new syntax and install the Pug package on npm. 31 32## Installation 33 34### Package 35 36via npm: 37 38```bash 39$ npm install pug 40``` 41 42### Command Line 43 44After installing the latest version of [Node.js](http://nodejs.org/), install with: 45 46```bash 47$ npm install pug-cli -g 48``` 49 50and run with 51 52```bash 53$ pug --help 54``` 55 56## Syntax 57 58Pug is a clean, whitespace sensitive syntax for writing html. Here is a simple example: 59 60```pug 61doctype html 62html(lang="en") 63 head 64 title= pageTitle 65 script(type='text/javascript'). 66 if (foo) bar(1 + 5) 67 body 68 h1 Pug - node template engine 69 #container.col 70 if youAreUsingPug 71 p You are amazing 72 else 73 p Get on it! 74 p. 75 Pug is a terse and simple templating language with a 76 strong focus on performance and powerful features. 77``` 78 79becomes 80 81 82```html 83<!DOCTYPE html> 84<html lang="en"> 85 <head> 86 <title>Pug</title> 87 <script type="text/javascript"> 88 if (foo) bar(1 + 5) 89 </script> 90 </head> 91 <body> 92 <h1>Pug - node template engine</h1> 93 <div id="container" class="col"> 94 <p>You are amazing</p> 95 <p>Pug is a terse and simple templating language with a strong focus on performance and powerful features.</p> 96 </div> 97 </body> 98</html> 99``` 100 101## API 102 103For full API, see [pugjs.org/api/reference.html](https://pugjs.org/api/reference.html) 104 105```js 106var pug = require('pug'); 107 108// compile 109var fn = pug.compile('string of pug', options); 110var html = fn(locals); 111 112// render 113var html = pug.render('string of pug', merge(options, locals)); 114 115// renderFile 116var html = pug.renderFile('filename.pug', merge(options, locals)); 117``` 118 119### Options 120 121 - `filename` Used in exceptions, and required when using includes 122 - `compileDebug` When `false` no debug instrumentation is compiled 123 - `pretty` Add pretty-indentation whitespace to output _(false by default)_ 124 125## Browser Support 126 127 The latest version of pug can be download for the browser in standalone form from [here](https://pugjs.org/js/pug.js). 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. 128 129 To compile a template for use on the client using the command line, do: 130 131```bash 132$ pug --client --no-debug filename.pug 133``` 134 135which will produce `filename.js` containing the compiled template. 136 137## Additional Resources 138 139Tutorials: 140 141 - cssdeck interactive [Pug syntax tutorial](http://cssdeck.com/labs/learning-the-jade-templating-engine-syntax) 142 - cssdeck interactive [Pug logic tutorial](http://cssdeck.com/labs/jade-templating-tutorial-codecast-part-2) 143 - [Pug について。](https://gist.github.com/japboy/5402844) (A Japanese Tutorial) 144 145Implementations in other languages: 146 147 - [Larpug - Pug for Laravel](https://github.com/acidjazz/larpug) 148 - [php](https://github.com/pug-php/pug) 149 - [scala](https://scalate.github.io/scalate/documentation/scaml-reference.html) 150 - [ruby](https://github.com/slim-template/slim) 151 - [python](https://github.com/SyrusAkbary/pyjade) 152 - [java](https://github.com/neuland/jade4j) 153 154Other: 155 156 - [Emacs Mode](https://github.com/brianc/jade-mode) 157 - [Vim Syntax](https://github.com/digitaltoad/vim-pug) 158 - [TextMate Bundle](http://github.com/miksago/jade-tmbundle) 159 - [Coda/SubEtha syntax Mode](https://github.com/aaronmccall/jade.mode) 160 - [html2pug](https://github.com/donpark/html2jade) converter 161 - [pug2php](https://github.com/SE7ENSKY/jade2php) converter 162 - [Pug Server](https://github.com/ded/jade-server) Ideal for building local prototypes apart from any application 163 - [pug-ruby](https://github.com/yivo/pug-ruby) gem: Allows to invoke Pug and Jade from Ruby 164 - [pug-rails](https://github.com/yivo/pug-rails) gem: Integrates Pug and Jade into your Rails application 165 166## License 167 168MIT 169