V
V
Vaultboy842019-09-25 12:47:40
Pug
Vaultboy84, 2019-09-25 12:47:40

Should I use pug(jade)?

The question is purely debatable. I already have an answer for myself, I wanted to hear alternative points of view of people from the profession. Personally, I do not see any advantages from using Pug, it reminds me of CoffeScript that has sunk into oblivion.
All its advantages are absolutely not obvious to me. Clear syntax - understandable only to those who have mastered it. Since the front is closely related to the back, I doubt that back programmers will be happy to see unfamiliar syntax, while everyone knows classic html. Pug, on the other hand, is syntactic sugar for them, which is still just an add-on over html. Reusable blocks? Well, this makes an elementary include in any server language, the same php. I may not have fully understood how Pug works, but it annoys me terribly that every change in the html structure is fraught with recompilation of the entire page. All of this slows things down. We made a change, recompile pug.
Explain what is its relevance at the moment? Thank you.

Answer the question

In order to leave comments, you need to log in

7 answer(s)
D
dom1n1k, 2019-09-25
@dom1n1k

My first experience with then Jade was about 6 years ago. And he was, to put it mildly, controversial. I kind of liked it, but not anymore. There were problems that repeatedly blocked the savings from the shortened syntax. I wrote somewhere on Habré a comment about this. In general, I gave up.
Then he returned several times and gradually came to the conclusion that if you get the hang of it, then you can still get some benefit. And it is important that over time the authors fixed some problems. It doesn't mean that I love Pug, but at least I was able to use it without getting constantly annoyed.
What exactly are the benefits? Allegedly cleaner indented code, lack of closing tags is all nonsense. Maybe dignity, but definitely minor. The main functionality that is completely absent in native HTML: mixins, auto-generation of blocks of the same type, template inheritance. This truth is not enough.
But there are two buts.
1. Is there a similar functionality in any other template engine? Right. And I looked at a few (nunchaku, slim, haml, dust). And everywhere I came across some annoying nuances or something was missing. And since the holy grail was not found, then I did not find any arguments for myself to change the awl to soap.
2. It is more convenient for me to resolve such issues at the front. If it is more convenient for you to do all the same in PHP - then yes, it turns out that there is not much point.

B
beduin01, 2019-09-25
@beduin01

At one time I refused it. layout approaches have changed and pug has only made life more difficult, not easier.

S
Sanes, 2019-09-25
@Sanes

What is wrong with HTML markup? It is both more readable and editors work adequately with it.

D
Dmitry, 2019-09-25
@i__dmitry

The more or less standard workflow using Pug is to use a build tool or taskrunner like Gulp or Webpack that fully automates the compilation of HTML from Pug, both in dev mode and in build. That is at competent setup of worker process the problem of recompilation described by you vanishes.
Relevance depends on the scope and nature of the tasks. A simple landing page or business card may or may not make sense with Pug. On more or less large projects, you can achieve a serious increase in speed due to the simplified syntax and additional features such as mixins and functions.
So, as with any tool, you first need to be clear about why and when to use it. If this understanding has not come, most likely, until the situation arises when the tool is really needed.

F
Froggyweb, 2019-09-25
@Froggyweb

And I like indents.
There are no "re-closed" tags, mixins on the menu for example
In general, the taste and color of the felt-tip pens are different

A
Alexey Nikolaev, 2019-09-25
@Heian

Well, essentially, yes. A template engine should be used when there are a lot of templates and they have repeating parts. My personal opinion is that syntactically Pug is better than Slim \ Smarty, but worse than Blade, which I admire.
Even when developing a front, it is worth using templates. The sources will be cleaner, and the speed of development will increase. But I would not use templates that are compiled in real time, precompilation is our everything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question