What is an "include template" in Express/Jade?
Solution 1
From the Express guide:
The Express view system has built-in support for partials and collections, which are “mini” views representing a document fragment. For example rather than iterating in a view to display comments, we could use partial collection.
So when you have the same "view" for a user in multiple pages, it's more useful to have that view stored in a file and "include" it everywhere. (DRY - Don't Repeat Yourself)
Another example is when have the same layout everywhere and you want to include the rest of the page (for example you could include different headers, footers and body depending on the page).
Here's a good example with Jade, provided in the Express samples:
https://github.com/visionmedia/express/tree/master/examples/jade/views
Solution 2
https://github.com/visionmedia/jade
It's there in one of the H2 headings.
Randomblue
Updated on June 08, 2022Comments
-
Randomblue almost 2 years
This article seems to suggest that there such things as
include
templates. I've made the obvious Google searches but didn't find any documentation.What are they?
-
Falcon over 10 yearsthe example code is very helpful. in short, the syntax is
include viewName