Search code examples
node.jsexpresspug

Express 4+pug disable layout


I want to ajax for blocks that without layout Such as

extends layout
block content
  p xxxx

I want to get the content in block

if !layout
  include layout

The solution


Solution

  • If you don't want the standard pug layout then create a file that doesn't have extends layout in it:

    doctype html
    html(lang='en-us')
      head
        title Page Title
      body
        div Content goes here
    

    You don't need to do anything in your app.js file to make this happen. You've probably figured out that none of the statements in your question work. This is all controlled in the pug template file.