Partials using Collection

27 views
Skip to first unread message

lutaeko

unread,
May 14, 2012, 12:02:17 PM5/14/12
to Express
Hi

I am having problems using partials with collection, it's not working.
This is my code:

app.js
app.get('/test', routes.test);

routes/index.js
var graphics_mod = [
{divName: 'div1' ,title: 'Title 1'},
{divName: 'div2' ,title: 'Title 2' },
{divName: 'div3' ,title: 'Title 3'},
{divName: 'div4' ,title: 'Title 4'}
];
exports.test = function(req,res) {
res.render('test', {graphics_var: graphics_mod})
};

test.jade
!= partial('partials/graphics',{collection: graphics_var});

partials/graphics.jade
div(id="graphics_var.divName") graphics_var.title

The best I could get was that four divs where created but no title or
div name, they show as undefined.
There's got to be something wrong, I just can't see it. I tried every
tutorial/video/helper I could find, but I am new here and out of
options..

Thank you in advance,
Lucia

lutaeko

unread,
May 21, 2012, 11:22:38 AM5/21/12
to Express
Problem solved:

modules/graphics.js
var graphics_mod = [
{divName: 'div1' ,title: 'Title 1'},
{divName: 'div2' ,title: 'Title 2' },
{divName: 'div3' ,title: 'Title 3'},
{divName: 'div4' ,title: 'Title 4'}
];

routes/index.js
var graphics_mod = require('../modules/graphics.js')
exports.test = function(req,res) {
res.render('test', {graphics_var: graphics_mod.all})
};

partials/graphics.jade
div(id="graphics.divName") graphics.title
Reply all
Reply to author
Forward
0 new messages