0

Can someone explain me the following code please. Actually just the first two lines.

app.engine("html", engines.nunjucks);
app.set("view engine", "html");
app.set("views", __dirname + "/views");

It confuses me.

The first line alone would make sense it me. I would say it connects the file-extension "html" to the engine nunjucks. So that the engine nunjucks is used when a file with the extension "hmtl" has to be processed. But what is then the purpose of the second line?

The two lines seem to be the same. It's just that the do the same thing in different notation. At least that way it seems to me.

Can someone clarify the coding-pattern for me?

1

1 Answer 1

2
  • The first approach is to map a different extension to this template engine.
  • The second approach is to set a default template engine in the app.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.