budlaha.blogg.se

Pug template conditional
Pug template conditional











Variables created this way can be of any data type that can be used in JavaScript. Though the example below isn’t practical, it helps to show how variables can be set and used in their simplest form. If you then just want to put that variable into the DOM as-is, an equals sign can accomplish that. Unlike php, where the code to be executed needs to be wrapped in a  tag, all that’s needed to set up a variable in Pug is a hyphen. pug file is very easy to do since it is a JavaScript templating language. Without further adieu, let’s get started! Creating and using variables within Pug Today I’m going to show you how you can use variables and logic in your templates to make them dynamic and flexible, allowing you to write one template to hold lots of different pieces of information that are all formatted the same rather than writing out a separate HTML file for each one. In my previous post, I showed you how to create elements in Pug with classes, ids, attributes, and nesting. Using the Pug Templating Engine Part 2 – Logic













Pug template conditional