Express & Jade, templates adding code to the layout


I’m playing around with an Express site with Node.JS

I have a layout file which, let’s say, looks like this:

title foo
body!= body

From what I have been able to understand, the output of the template is inserted into a variable called body and that's added to the layout there on the 3rd line. However, if I wanted a template to add, for example, a <meta> tag in the <head> element, how would I do that?

I did see the explanation of extending templates and using blocks, but I’m not sure how that ties it to using layouts. The templates themselves shouldn’t be extending the layout, right? Or, does template inheritance remove the need for layouts at all? I would suspect not, but I’m not sure.

Also, since I’m here, how do you specify a different layout to be used, or for no layout to be used at all. Currently, the views are being rendered like this:

res.render('templateName', { myTemplateVars : 'foo' });

Problem courtesy of: nickf


What you are asking for was released 3 days ago.

I have personally been using it for a few weeks and love the recent additions. The block statement allows you to specify default content and any extension template can override a named block.

Basically, blocks override, includes append and extends chooses your parent template.

Solution courtesy of: collinwat

View additional discussion.