Reputation: 898
I'm reading the guide to templating engines (ejs/Jade) for Express.
They make a lot of references to layouts and partials?
What are they?
Upvotes: 1
Views: 243
Reputation: 195
You can think layout as a main class and all the css file extends it. Layout is the basic structure of our css.For Eg:-
layout.jade
doctype 5
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
body
block content
so our main file will be
index.jade
extends layout
block content
#wrapper
#img
a(href='/')
img(src='/images/img.png')
#display
#login
form(method='post')
| Enter your name
div
input(type='text', name='username')
input(type='submit', value='Log In')
But be careful about the spacing... ;)
Upvotes: 0
Reputation: 331
Layouts are basically the overall structure of a page. So for example, the opening html tag, head section, body, etc. defining the structure of the page, where regions and sidebars and whatnot are.
Partials, on the other hand, are small snippets of markup. Building blocks of the page. So, suppose you had a site with a top nav bar, main content area, and a sidebar. Your nav would probably be a partial, the main content area would be made up of several instances of partials. In the case of a blog, on the home page the main content area would have several instances of the same partial rendered.
So, really, their names are quite literal. Layouts define the overall layout of a page, and partials are pieces -- parts -- of the page.
See also: http://www.hacksparrow.com/express-js-jade-partials-how-to-use-them.html
and, while not related to expressjs or node, the concepts still apply: https://github.com/handlino/FireApp/wiki/Templates,-layouts,-and-partials
Upvotes: 1