Render single block in jade

I'm working with Node.js and express. Suppose I have a pair of jade files:

template.jade

html
  body
    block page-content

example.jade

extends template
    block page-content
        p
           |  Lorem ipsum yadda yadda

If I render example.jade, I'll get the result of plugging that paragraph tag into the body tag of template.jade, which is normally what I'd like.

My problem is that I'm trying to use pushState and the History API to load these files (well, obivously not -these- files), and when doing that, I want a request that just returns the content of the page-content block itself, without the rest of the full html document. Is there a simple way to tell Jade to just render the block itself and not embed it into the template?


The best I could come up with was changing it to be:

example.jade

extends template
  block page-content
    import example-content

example-content.jade

p
  | Lorem ipsum yadda yadda

But it seemed hackish to create extra files like this.

Jade supports executable code. When used prefixed - (without buffering). For example you can use if statment in main layout jade template:

- if (renderType && renderType == 'page') {
    doctype 5
    html
      head
        title= title
      body
- }
        block content

Render html page like:

  res.render('index', { title: 'StackOverflow', renderType: 'page' });

Render html block like:

  res.render('index', { title: 'StackOverflow', renderType: 'block' });

And if you don't like use renderType variable in all render expressions, use

res.locals(obj) //*Assign several locals with the given obj. The following are equivalent:*

and set default value for all requests. Where you init app add handler:

var logger = function(req, res, next)
{
    res.locals({renderType:'page'});
    next();
};

app.use(logger);