how to pass variables between jade templates

Billy Moon picture Billy Moon · Sep 28, 2012 · Viewed 20.8k times · Source

I am using a template as a base, and want it to be aware of some variables set in the page that is using it...

File: template.jade

vars = vars || {some:"variables"}
!!! 5
head
    title vars.some

File: page.jade

vars = {some:"things"} //- this does not get used from within template.jade
extends template

I want the compiled page.jade to have a title "things"

Answer

Roman Rhrn Nesterov picture Roman Rhrn Nesterov · Jun 14, 2013

I find solution here

pass block with variables

template.jade:

!!!
html
  block vars
  head
      title #{pageTitle} - default www title
  body

page.jade

extends template
block vars
  - var pageTitle = 'Home'