bminer / node-blade

Blade - HTML Template Compiler, inspired by Jade & Haml
Other
320 stars 28 forks source link

use Meteor.Collection.forEach() with Template.noname ? #73

Closed crapthings closed 12 years ago

crapthings commented 12 years ago
Meteor.ui.render(function() {
    var users = Users.find().fetch();
    users.forEach() // use blade template here ?
});
bminer commented 12 years ago

Sure... there are many ways to accomplish something like this. You can try:

Meteor.ui.render(function() {
    var cursor = Users.find(), html = "";
    cursor.forEach(function(user) {
        html += Template.user({"user": user});
    });
    return html;
});

Another way might be to write a Blade template:

For this, we'll assume that user.blade also exists and contains a function called user.

users.blade

include "user"
- var cursor = Users.find();
- cursor.forEach(function(user)
    call user(user)
- )

and render using Meteor.ui.render(Template.users);