| 1 | <h2>Comments</h2> |
| 2 | <pre><code>// Some |
| 3 | multiline |
| 4 | comment ! |
| 5 | |
| 6 | // This is a comment |
| 7 | But this is not</code></pre> |
| 8 | |
| 9 | <h2>Doctype</h2> |
| 10 | <pre><code>doctype html |
| 11 | doctype 1.1 |
| 12 | doctype html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"</code></pre> |
| 13 | |
| 14 | <h2>Tags</h2> |
| 15 | <pre><code>ul |
| 16 | li Item A |
| 17 | li Item B |
| 18 | li Item C |
| 19 | foo(bar='baz')/ |
| 20 | input(type='checkbox', checked=true.toString()) |
| 21 | #content |
| 22 | div#foo(data-bar="foo")&attributes({'data-foo': 'bar'})</code></pre> |
| 23 | |
| 24 | <h2>Markup</h2> |
| 25 | <pre><code><div class="foo bar"></div></code></pre> |
| 26 | |
| 27 | <h2>Control flow</h2> |
| 28 | <pre><code>#user |
| 29 | if user.description |
| 30 | p.description= user.description |
| 31 | else if authorised |
| 32 | p.description. |
| 33 | User has no description, |
| 34 | why not add one... |
| 35 | else |
| 36 | p.description User has no description |
| 37 | ul |
| 38 | each val in [1, 2, 3, 4, 5] |
| 39 | li= val |
| 40 | case friends |
| 41 | when 0 |
| 42 | p you have no friends |
| 43 | when 1 |
| 44 | p you have a friend |
| 45 | default |
| 46 | p you have #{friends} friends |
| 47 | </code></pre> |
| 48 | |
| 49 | <h2>Inline JavaScript</h2> |
| 50 | <pre><code>script alert('test'); |
| 51 | script(type="text/javascript"). |
| 52 | alert('foo'); |
| 53 | alert('bar'); |
| 54 | - var classes = ['foo', 'bar', 'baz'] |
| 55 | - for (var x = 0; x < 3; x++) |
| 56 | li item |
| 57 | </code></pre> |
| 58 | |
| 59 | <h2>Keywords</h2> |
| 60 | <pre><code>include ./includes/head.pug |
| 61 | extends ./layout.pug |
| 62 | block content |
| 63 | append head</code></pre> |
| 64 | |
| 65 | <h2>Mixins</h2> |
| 66 | <pre><code>mixin list |
| 67 | ul |
| 68 | li foo |
| 69 | li bar |
| 70 | li baz |
| 71 | +list |
| 72 | mixin pet(name) |
| 73 | li.pet= name |
| 74 | ul |
| 75 | +pet('cat') |
| 76 | +pet('dog') |
| 77 | </code></pre> |
| 78 | |
| 79 | <h2>Filters</h2> |
| 80 | <p>Filters require the desired language to be loaded. |
| 81 | On this page, check CoffeeScript <strong>before</strong> checking Pug should make |
| 82 | the example below work properly.</p> |
| 83 | <pre><code>script |
| 84 | :coffee |
| 85 | console.log 'This is coffee script'</code></pre> |