I’m curious about why templates like Pug (formerly Jade) don’t adhere to HTML syntax by having tags within HTML elements. However, it appears that Firebase isn’t compatible with Pug templates since I received a 404 error page not found when using “index.pug.
As a newcomer to Node.js, I have a query regarding unconventional templates such as Pug (previously known as Jade) that do not comply with the standard HTML syntax. It appears to me that this adds an extra layer of complexity. Could someone please enlighten me on the rationale behind this approach, or am I overlooking something?
Why a template engine?
can enhance the view functionality by preventing
of code in the template. This leads to cleaner templates and allows for easier implementation of iterators, mixins, variables, layout extensions, and more. As a result, the view becomes less technical and more self-sufficient, independent of the controller’s work. The ultimate goal is to create a template that can respond to data input without the need for front-end developers to worry about the backend methods being called.
Why a language structured by indent?
Using languages like Pug, Haml, Yaml, or Slim-lang that are structured by indent can save you time and prevent errors. By reducing the amount of code you need to write, you lower the risk of making typos or mistakes like using
. Every unnecessary character of code increases the likelihood of errors. Additionally, using less code can make it easier to understand the meaning behind it. While this is subjective, many people find Pug to be a clearer option. Structured indentation also ensures that everyone properly indents their templates.
Is an additional step a bad thing?
Production does not require re-compilation because users can simply render compiled templates.