![]() If you are used to template engines that use HTML and interpolate variables, like Handlebars (described next), you might run into issues, especially when you need to convert existing HTML to Pug. Installing Pug is as simple as running npm install : npm install pug Setup Pug to be the template engine in ExpressĪnd when initializing the Express app, we need to set it: const path = require('path')Īpp.set('views', path.join( dirname, 'views'))Ĭreate an about view: app.get('/about', (req, res) => This online converter from HTML to Jade (which is very similar, but a little different than Pug) will be a great help: Install Pug You can bind input data, use loops, conditions or javascript helpers to. While is another kind of loop: - var n = 0 More importantly, as a templating language, Pug has many features that HTML does not, such as simple coding constructions like conditional and case. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |