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"?
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}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With