Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Express Basics!
You have completed Express Basics!
Preview
Pug templates can contain logic you can use to make them more versatile. You can show or hide parts of the page conditionally, or iterate over arrays of data to express tables or lists more concisely.
Snippet Used in the Video
const colors = [
'red',
'orange',
'yellow',
'green',
'blue',
'purple'
];
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
the truth is pug lets you go further and
add basic programming logic to templates.
0:00
For example, you can display a good
when your app knows a user's name.
0:01
But hide the button if the user
hasn't entered it yet.
0:06
You could write a conditional
statement to handle that.
0:09
Or suppose you want to hand
a template a list of things and
0:12
have that list rendered in the HTML.
0:15
You could use a loop to do that.
0:18
Let's see how to use these
two features in templates.
0:20
First, I'll show you what happens
when I delete this hint from the app.
0:24
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up