How to pass an object's properties as the locals to an include in Jade?

javascript, pug, template-engine, templates

Solution

As the newest jade version (0.27.4) You can pass object reference as the same name of template

for thing in things
  include thing

will automatic include ./thing.jade with thing as object in thing.jade:

li
  h3 #{thing.title}
  p #{thing.description}

Problem

I'd like to pass an object inside a loop as follows; data structure: ``` things = [ { title: 'foo' , description: 'bar' } , { title: 'baz' , description: 'bam' } ]; ``` index.jade: ``` - for thing in things include things-template ``` In the above format, I'd like to be able to specify a parameter of some sort as "locals" for that include. things-template.jade: ``` li h3 #{title} p #{description} ``` Is this possible, or do I need to assign it to another variable and reference it inside my "thing-template"?

Original source