javascript - Pass variables to base layout from extending pug/jade template -
i set class on body tag declaring variable in template extends base layout.
when try, body_class
variable undefined
in layout.
it appears layout executed before extending template, or executed in different scopes or something.
is there way? 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
ah ha! figured out.
create block @ top of base layout , add variables in there.
_layout.jade:
block variables 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:
extends _layout block variables - var body_class = 'i-am-the-home-page' block header h1 home
Comments
Post a Comment