Y
Y
Yaroslav Kornilov2017-05-09 16:26:57
Node.js
Yaroslav Kornilov, 2017-05-09 16:26:57

Pug: what does this line do?

The pug documentation is frail. Can you elaborate on how this works:

// Compile the source code
const compiledFunction = pug.compileFile('template.pug');

Why do we then pass the compiledFunction object with template variables, because it's not like a function? Can anyone guess why the work of the most popular node templating engine was organized this way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lekha Yarkov, 2017-05-09
@yaroslavkornilov

const compiled Function = pug.compileFile('template.pug');

Doesn't bother anything? =)
We get the function by compiling the template. We pass an object with variables there and get the result. I think everything is fine =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question