pug
npm install -g pug-cli
pug -w ./ -o ./html -P
-w
-o
-P
p Text here
p.my-text Text here
<p>Yes!, HTML code is valid</p>
<p>Text here</p>
<p class="my-text">Text here</p>
<p>Yes!, HTML code is valid</p>
// THIS COMMENT IS PUBLIC (VISIBLE AS HTML COMMENT)
div.container
//- THIS COMMENT IS PRIVATE (NOT VISIBLE IN HTML)
div.container
<!--THIS COMMENT IS PUBLIC (VISIBLE AS HTML COMMENT)-->
<div class="container"></div>
<div class="container"></div>
div.container
p(style="color: red;") I'm red
p(style={"color": "red"}, class="test") I'm red
<div class="container">
<p style="color: red;">I'm red</p>
<p style="color: red;" class="test">I'm red</p>
</div>
//- another-file.pug
p I'm from another pug template
//- index.pug
div
include ./another-file.pug
p I'm from index template
<div>
<p>I'm from another pug template</p>
<p>I'm from index template</p>
</div>
- let myVar = "Text from JavaScript variable";
p= myVar
<p>Text from JavaScript variable</p>
- const myTable = ["First", "Second", "Third"]
- for (let i = 0; i < myTable.length; i++)
p= myTable[i]
each item in myTable
p= `${item} from each`
<p>First</p>
<p>Second</p>
<p>Third</p>
<p>First from each</p>
<p>Second from each</p>
<p>Third from each</p>
- let myString = "string with <em>Italic</em> font"
//- Escaped
p #{myString}
//- Unescaped
p !{myString}
//- Tag
p !{myString} #[b Bold text]
<p>string with <em>Italic</em> font</p>
<p>string with <em>Italic</em> font</p>
<p>string with <em>Italic</em> font <b>Bold text</b></p>
mixin generateLink(hyperRef, text, className)
a(href=hyperRef, class=className) !{text}
+generateLink("#", "Link Text", "link")
<a href="#" class="link">Link Text</a>
//- father.pug
p Text from the father
//- child.pug (compiled)
extends ./father.pug
<p>Text from the father</p>
//- father.pug
p Text from the father
block mySon
span He's 9 years-old
//- child.pug (compiled)
extends ./father.pug
block mySon
span No father, I just celebrated my 10 years yesternight
<p> Text from the father
<span>No father, I just celebrated my 10 years yesternight</span>
</p>
- const friends = 10
case friends
when 0
p you have no friends
when 1
p you have a friend
default
p you have #{friends} friends
<p>you have 10 friends</p>
Thanks for listening
Questions?
1/19