bminer / node-blade

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

Possible to use part of chunk inside a .blade template ? #72

Closed crapthings closed 12 years ago

crapthings commented 12 years ago

like a different display style with same meteor.collection eg: to display one for list style, one for card style with a switchable button, but put it in one template file.

bminer commented 12 years ago

I don't understand the question. Could you please elaborate?

crapthings commented 12 years ago

maybe something like

Template['personnel/employees'].__.chunk.list

or

Template['personnel/employees'].__.chunk.card

use one template file or separate into mutiple files?

mutiple seems easy

bminer commented 12 years ago

Interesting idea. So, you are trying to use chunks defined in one template in another template? Or, where do you want to refer to these chunks?

Right now, you can include a template, which also pulls in all defined functions, blocks, and chunks. I think I'd like to know more about your specific use-case.

crapthings commented 12 years ago

just like the first comment, maybe there's a way i can put my employees info into gallery style use like

chunk employees_gallery(employee)
    li
        a
            img(src=employee.photo)
            |= employee.name

chunk employees_list(employee)
    tr
        td= employee.name
bminer commented 12 years ago

Yes, this can be done already, I believe. The chunks aren't exposed via the Template object, but you can still include a template from another template.

For example:

employeeTable.blade

include "employees"
table
    != Meteor.ui.listChunk(Employees.find(), __.chunk.employees_list)

employeeGallery.blade

include "employees"
ul
    != Meteor.ui.listChunk(Employees.find(), __.chunk.employees_gallery)

Your employees.blade file contains both chunks... just like your previous comment.

bminer commented 12 years ago

Closing this issue for now...