Pug: what does this line?

Documentation, pug hill. Can you explain (expand) works like this:
// Compile the source code
const compiledFunction = pug.compileFile('template.pug');


Why we share compiledFunction object with the variables of the template, it doesn't seem to function? Can anyone suggest why it was organized the work of most popular templating engine node?
June 26th 19 at 14:26
1 answer
June 26th 19 at 14:28
Solution
const compiledFunction = pug.compileFile('template.pug');

Why do we then pass the compiledFunction object with the variables of the template, because it did not seem to function?

Does not bother anything? =)
Get a function to compile the template. Pass back an object with variables and get the result. I think everything is OK =)
Yes)
But compiledFunction I translated as "compiled function"...
So why break the process? Not practical to have to pass and file and value? - Fanni commented on June 26th 19 at 14:31
: for multiple use. Below each rendering without having to compile it, and doing it once - idella_Stoltenberg2 commented on June 26th 19 at 14:34
And in vain I sinned on the documentation, it is though meager, but this point clarifies
The general rendering process of Pug is simple. pug.compile() will compile the Pug source code into a JavaScript function that takes a data object (called “locals”) as an argument. The resultant Call that function with your data, and voilà!, it will return a string of the rendered HTML with your data.


And still wondering why it was so split up.. - Fanni commented on June 26th 19 at 14:37
by the way they have and that implementation which I think is more logical

pug.renderFile('template.pug', {
name: 'Timothy'
})
- Fanni commented on June 26th 19 at 14:40
: I know ))) - idella_Stoltenberg2 commented on June 26th 19 at 14:43
you said why break up. So once the template was compiled with a different data renderest. - ned.Frami22 commented on June 26th 19 at 14:46

Find more questions by tags Node.jsPug