I would like to set a class on the body tag by declaring a variable in a template that extends a base layout.
When I try, the body_class
variable is undefined
in the layout.
It appears the layout is executed before the extending template, or they are executed in different scopes or something.
Is there another way? Would a mixin work here?
_layout.jade:
doctype html
html(lang="en-au")
head
meta(charset="utf-8")
block css
body(class=(body_class || "it-did-not-work"))
block header
block content
block footer
home.jade:
var body_class = 'i-am-the-home-page'
extends _layout
block header
h1 home