D
D
doroshenko_magic2017-12-26 20:13:40
Pug
doroshenko_magic, 2017-12-26 20:13:40

How is a preprocessor different from a template engine?

How is a preprocessor different from a template engine? And why is pug both the one and the other?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
Konstantin Kitmanov, 2017-12-27
@doroshenko_magic

The template engine allows you to display variables and sometimes organize simple logic (loops, conditions).
The preprocessor expands or changes the syntax.
Pug does both the first and second :)

R
Roman Kitaev, 2017-12-26
@deliro

Template engine:

- var friends = 10
case friends
  when 0
    p you have no friends
  when 1
    p you have a friend
  default
    p you have #{friends} friends

->
->
<p>you have no friends</p>

S
s-jet, 2017-12-26
@s-jet

because it both collects the code and modernizes it into full-fledged HTML, as user wrote above)

E
Egor Zhivagin, 2017-12-27
@Krasnodar_etc

The template engine receives data (from the backend, for example) and inserts it into the template, organizing minimal logic (loops, branches, ...). Take a look at EJS for example. It doesn't affect the html syntax at all.
The preprocessor has nothing to do with the input data, it just makes it easier to work with HTML . Along the way, modifying the syntax for convenience.
Pug is used for both tasks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question