By default, text at the start of a line (or after only white space) represents an HTML tag. Indented tags are nested, creating the tree structure of HTML.
ul li Item A li Item B li Item C
<ul> <li>Item A</li> <li>Item B</li> <li>Item C</li> </ul>
Pug also knows which elements are self-closing:
To save space, Pug provides an inline syntax for nested tags.
Tags such as
link are automatically self-closing (unless you use the XML doctype).
You can also explicitly self close a tag by appending the
/ character. Only do this if you know what you’re doing.
<foo/> <foo bar="baz" />
Whitespace is removed from the beginning and end of tags, so that you have control over whether the rendered HTML elements touch or not. Whitespace control is generally handled via plain text.
© Pug authors
Licensed under the MIT license.