Is there a way to check witch page are you in Jade and include something(a partial page or a specific CSS Style) based in that page? For example:
If i am in homepage, then include just the HOMEPAGE-head.jade
Else include the NORMAL-head.jade
Here is an in context example:
doctype html
html
body
if HOMEPAGE
include ./includes/HOMEPAGE-head.jade
else
include ./includes/NORMAL-head.jade
h1 My Site
p Welcome to my super lame site.
include ./includes/foot.jade
Thank you!
There are two approaches I know of.
Make two layouts: layout.jade and layout-homepage.jade, changing the include line accordingly. Most of your pages will extends layout, but index.jade will extends layout-homepage.
in layout.jade:
- var HOMEPAGE = false;
block variables
doctype html
html
body
if HOMEPAGE
include ./includes/HOMEPAGE-head.jade
else
include ./includes/NORMAL-head.jade
h1 My Site
p Welcome to my super lame site.
include ./includes/foot.jade
Then in index.jade:
block variables
- HOMEPAGE = true;
h1 This is your home page template...
All the rest of your pages will default to HOMEPAGE = false so they don't need any changes to make this approach work.
Alternatively you can structure your Jade to use inheritance to achieve what you want.
E.g.,
layout.jade:
doctype html
html
body
block header
block content
h1 My Site
p Welcome to my super lame site.
block footer
include ./includes/foot.jade
homepage.jade:
extends ./layout.jade
block header
include ./includes/HOMEPAGE-head.jade
normal.jade:
extends ./layout.jade
block header
include ./includes/NORMAL-head.jade
And then have all your normal pages use normal.jade and your homepage to use homepage.jade.