Saturday, 15 May 2010

javascript - Pass variables to base layout from extending pug/jade template -


I want to declare a base in a template and set a class on body tags that increases the base layout .

When I try, the body_class variable is undefined in the layout.

It seems that layouts are executed before extended templates, or they are executed in various scopes or something.

Is there any other way? Will a mixine work here?

_layout.jade:

  html html (lang = "en-au") head meta (charset = "UTF-8") Block CSS body (class = (body_class || "this-no-work")) Block header block content block footer  

Home z:

  var body_class = 'I-m-the-home-page' extension _layout block header h1 home  

Ahhhh! Figure it out.

Create a block at the top of the base layout and add its variable there.

_layout.jade:

(preset) block variable doctype html html (lang = "en-au") head meta (charset = "utf-8" Block CSS Body (class = (body_class || "This-no-work") Block header block content block footer block

home.jade:

  extended _layout block variable - var body_class = 'i -m-home-page' block header H1 home  

No comments:

Post a Comment