Skip to content

Instantly share code, notes, and snippets.

@viktorbezdek
Last active February 16, 2022 18:03
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save viktorbezdek/9665226 to your computer and use it in GitHub Desktop.
Save viktorbezdek/9665226 to your computer and use it in GitHub Desktop.
Jade - pass variable to base layout from extending template

layout.jade

doctype 5
html.no-js(lang='en')
block vars
head
  title #{title}
  meta(name='description', content='#{description}')
body
  block content

page.jade

extends layout

block vars
  - var title='Home'
  - var description = 'Welcome to my page'

block content
  p Hello world!

This solution came from Jade issue discussion.

@chrisdel101
Copy link

chrisdel101 commented Nov 7, 2019

Thanks for this! This is way more popular https://stackoverflow.com/questions/29089925/pass-variables-to-base-layout-from-extending-pug-jade-template, but yours is more descriptive w/ an example of how to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment