Search code examples
node.jspugblock

Blocks not working with nodejs and jade


Reading for hours, I am pretty sure I understand how blocks in Jade work. Here is my layout.jade file:

!!! 5
html(lang="en")
  head
    title= title
    link(rel= 'stylesheet', href= '/style.css')
  body
    h1 Placeholder Title
    block content

And my index.jade file

extends layout
block content
  p Hello World

However, when I visit index.jade the only thing that shows up is

"Placeholder Title"

The "content" block in layout.jade never gets replaced by the content block in index.jade


Solution

  • For blocks to work you need to do { layout: false }. More information can be found in the docs: https://github.com/visionmedia/jade#template-inheritance