JavaScript Express Basics Using Templates with Express Express’s Response.render Method

Vitaly Khe
Vitaly Khe
7,155 Points

Why do we use different syntax using "prompt" and "hint" variables in .pug?

h1= prompt
i: #{hint}

Can we set h1 value like this?

h1: #{prompt}
Rochelle Burrows
Rochelle Burrows
4,195 Points

I had this question myself and tested it. Looks like they are just two different ways to insert data dynamically into a pug template. The ":" was just part of the sentence. When you look at the result in the browser, the paragraph section reads like this:

Hint: Think about whose tomb it is

The "i" stands for italics, by the way. So the HTML stynax next to the pug syntax would look like this:

HTML:

<i>Hint: Think about whose tomb it is</i>

PUG:

i Hint: #{hint}

The "hint" variable is equal to the string: "Think about whose tomb it is", and "Hint:" is part of the sentence.