
This means it’s a tool that generates documents from templates that integrate some specified data. Pug (formerly known as Jade) is a template engine. You’ll learn how to install Pug in your Angular apps and transition existing apps that use HTML to use Pug. In this article, I’ll cover how you - as an Angular developer - can use Pug to write better templates more efficiently. This is in spite of many more efficient options such as Pug, Slim, HAML among others being in existence. However, when it comes to templates, only two options are available: HTML and SVG. Components provide an amazing means to structure views, facilitate code reusability, interpolation, data binding, and other business logic for views.Īngular CLI supports multiple built-in CSS preprocessor options for component styling like Sass/SCSS, LESS, and Stylus. In this article, Zara Cooper explains what Pug is and how you can use it in your Angular app.Īs a developer, I appreciate how Angular apps are structured and the many options the Angular CLI makes available to configure them. In Angular, you can use Pug to write component templates and improve a project’s development workflow. “Developing template engines for Express”.ĭocumentation translations provided by StrongLoop/IBM:įrench, German, Spanish, Italian, Japanese, Russian, Chinese, Traditional Chinese, Korean, Portuguese.Ĭommunity translation available for: Slovak, Ukrainian, Uzbek, Turkish and Thai.Pug is a template engine that allows you to write cleaner templates with less repetition. To learn more about how template engines work in Express, see: The view is still re-rendered with every request even when the cache is on. Note: The view engine cache does not cache the contents of the template’s output, only the underlying template itself. When you make a request to the home page, the index.pug file will be rendered as HTML. You must specify the extension of the view file.


Then create a route to render the index.pug file. app.set('view engine', 'pug')Ĭreate a Pug template file named index.pug in the views directory, with the following content: html Library follows this convention by mapping all of the popular Node.js template engines, and therefore works seamlessly within Express.Īfter the view engine is set, you don’t have to specify the engine or load the template engine module in your app Įxpress loads the module internally, as shown below (for the above example). Some template engines do not follow this convention. Which is called by the res.render() function to render the template code. Express-compliant template engines such as Jade and Pug export a function named _express(filePath, options, callback),
