In both cases the default behavior is to escape the line. In the second line the paragraph content is a text string concatenated with the title variable. So for example, in the first line below, the content of the h1 tag will be variable title (either defined in the file or passed into the template from Express). If a tag is followed by the equals sign, the following text is treated as a JavaScript expression.
#EXAMPLE PUG TEMPLATE CODE#
characters like " >" are converted to their HTML code equivalents like " >") to prevent JavaScript injection or cross-site scripting attacks. The values of all attributes are escaped (e.g.
#EXAMPLE PUG TEMPLATE INSTALL#
The PUG template contains static markup for the page layout that makes the appearance similar for each employee. Let’s install PUG in our Node application as a dependency.
#EXAMPLE PUG TEMPLATE UPDATE#
Pug allows developers to create webpages with re-usable static markup, while inserting dynamic elements on the pages that will be filled with information from an external source, like a database, later.įor example, a developer may use a PUG file when creating a website where employees of a company can update their personal information. You will most likely only encounter a PUG file if you are a web developer utilizing the Pug templating engine for generating dynamic HTML webpages. PUG file open in Microsoft Visual Studio Code