Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

Pug

< >

Pug is an open source template language created in 2010 by Tj Holowaychuk.

#63on PLDB 14Years Old 12kRepos
Download source code:
git clone https://github.com/pugjs/pug
Homepage · REPL · Source Code · Docs

Pug – robust, elegant, feature rich template engine for Node.js


Example from Riju:
html body p Hello, world!
Example from hello-world:
doctype html html head title Hello World body h1 Hello World
Example from Linguist:
p. Hello, World!
append block case default doctype each else extends for if in include mixin typeof unless var when

Language features

Feature Supported Example Token
Inheritance ✓
Comments ✓ // A comment
Line Comments ✓ // A comment //
Strings ✓
Assignment ✓ - var title = "On Dogs: Man's Best Friend"; h1= title
Functions ✓ mixin article(title) .article .article-wrapper h1= title if block block else p No content provided +article('Hello world') +article('Hello world') p This is my p Amazing article
Switch Statements ✓ - var friends = 10 case friends when 0 p you have no friends when 1 p you have a friend default p you have #{friends} friends
Conditionals ✓ - var user = {description: 'foo bar baz'} - var authorised = false #user if user.description h2.green Description p.description= user.description else if authorised h2.blue Description p.description. User has no description, why not add one... else h2.red Description p.description User has no description
File Imports ✓ //- index.pug doctype html html include includes/head.pug body h1 My Site p Welcome to my super lame site. include includes/foot.pug
hasForEachLoops ✓ ul each val in [1, 2, 3, 4, 5] li= val
Semantic Indentation ✓

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v161.0.4