Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

how to render multiple jade templates

how to render multiple jade templates

Problem

I am trying to understand how JADE works when there are several templates.

I worked by this tutorial: http://www.franz-enzenhofer.com/jade

But, I got this:

$ curl http://localhost:3000

Franz Enzenhofer

It seems that the command "res.render('index.jade',..." only took the index.jade template, but didn't insert it into the layout.jade template as should happen...

Problem courtesy of: Erel Segal-Halevi

Solution

I assume you are using partials. They were removed with express v3. See the View System Changes part for more information.

From express v3 on you should use blocks. For example:

my-template.jade:

extends my-layout

block head
  script(src="myfile.js")

block content
  h1 My page

my-layout.jade

doctype 5
html
  head
    title My title
    block head
  body
    #content
      block content
Solution courtesy of: zemirco

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

how to render multiple jade templates

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×