I tried everything to make this template work but still this error: Only named blocks and mixins can appear at the top level of an extending template

Viewed 3421

Only named blocks and mixins can appear at the top level of an extending template. Its killing me and i cant understand why this is not working. Im new to pug and maybe i should be using something called mixins.

//layout.pug

doctype html
html   
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
    link(rel='stylesheet', href='https://www.w3schools.com/w3css/4/w3.css')
    script(src="https://cdn.auth0.com/js/auth0/8.7/auth0.min.js")
    link(href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',rel='stylesheet')
    script(src='https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js')
    script(src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js') 
  body
    nav.w3-bar.w3-border.w3-light-grey( role="navigation" )

      if loggedIn
        a(href="/getposts").w3-bar-item.w3-button All Customers
        a(href="/gethotposts" ).w3-bar-item.w3-button HOT Customers
        a(id="qsLogoutBtn" href="/logout").w3-bar-item.w3-button Logout
      else
        a(id="qsLoginBtn" href="/login").w3-bar-item.w3-button Login
        a(href="/getposts").w3-bar-item.w3-button All Customers
        a(href="/gethotposts" ).w3-bar-item.w3-button HOT Customers

    block content

//customers.pug

extends layout

block content
table.table.table-striped(style='width:700px')(align='center')
  thead
    tr
       th First Name
       th Last Name
       th Email
       th Status
  tbody
    each value in customer
      tr
         td=value.First_Name
         td=value.Last_Name
         td=value.Email
         td=value.Status
1 Answers

This is something that happens to me all the time when I'm in a hurry and don't check the indentation carefully.

block content
table.table.table-striped(style='width:700px')(align='center')

You need to indent your tags by two more spaces to be UNDER the block content and not EVEN with it:

extends layout

block content
  table.table.table-striped(style='width:700px')(align='center')
    thead
      tr
        th First Name
        th Last Name
        th Email
        th Status
    tbody
      each value in customer
        tr
          td=value.First_Name
          td=value.Last_Name
          td=value.Email
          td=value.Status
Related