I am trying to write a template that renders a double indexed array. So I started writing this:
- var grid = [[1, 0, 1], [0, 1, 0]];
each row in grid
each cell in row
if cell
span x
else
span o
but this is not how I want to write my array I want to write it like this:
- var grid = [[1, 0, 1],
[0, 1, 0]];
This doesn't work because jade is already out of the inline javascript
- var grid = [[1, 0, 1],
- [0, 1, 0]];
This doesn't work because jade considers those two incorrect lines instead of one line
How can I make it work?
Update: Multiline defs are now working for me using Jade 1.11.0
. Even nested JSON now works like a charm.
-
projects = [{
title: "Project 1",
classname: "project1",
slides: [{
title: "Slide 1"
img: "images/hello.png"
},{
title: "Slide 2"
img: "images/world.png"
}]
}, {
title: "Project 2",
classname: "project2",
slides: [{
title: "Slide 3"
img: "images/fun.png"
},{
title: "Slide 4"
img: "images/things.png"
}]
}]
EDIT: Yay, these are real! Go check out the other answer on how to pull this off.
Sadly, this is currently not possible in Jade. TJ (the maintainer) has stated that he does not care about this, but would welcome a feature request. https://github.com/visionmedia/jade/issues/796
Fortunately, you can declare the array in your JS file and pass it as a variable to Jade.
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