0

My Problem: I cannot get my jade blocks to extend
My Setup: Running the latest NodeJS with Express 3

I'm loading some HTML via Ajax using a Post method

app.post "/utilities", (req, res) ->
  res.render "utilities", layout:false

In Utilities I have the content, and I'm trying to break up everything into chunks so that this page isn't so busy

// utilities.jade

div#topPanel
  section#toolMenu
    block tool // <- won't load

  div#rightPanel
    section#screen
    section#userWindow
      block user // <- won't load

section#chatWindow
  block chat // <- won't load (example case)

And lastly I have the individual blocks that follow this structure

// chat-block.jade
extends utilities

block chat
  div.inner
    div.left
      form#chat-input
        textarea
    div.window
      div.full
Marius Miliunas
  • 1,023
  • 18
  • 34

1 Answers1

2

I think what you want to do is to include chunks of jade into your main file.

Change to following code

section#chatWindow
  block chat // <- won't load (example case)

to

section#chatWindow
  include chat

and your chat-block.jade to

div.inner
  div.left
    form#chat-input
      textarea
    div.window
      div.full

Then it works fine!

zemirco
  • 16,171
  • 8
  • 62
  • 96
  • 1
    AFAIK `include` is the "top-down" approach. You render your main template and this pulls all the subtemplates. `block` on the other hand is more "bottom-up". You render your subtemplate, in this case the chat, and it looks upwards if it is part of a main template with header, footers, etc. and gets this content. – zemirco Oct 02 '12 at 07:28