Specifying locals for an include

43 views
Skip to first unread message

Elliot

unread,
Apr 21, 2013, 9:34:57 PM4/21/13
to jad...@googlegroups.com
I have two templates.  One is an item, and the other is a list of items.  I would like to be able to reuse the individual item when rendering the list.

I cannot do so because the list form specifies the item in addition to the item's attributes.

I made a gist demonstrating the problem:  https://gist.github.com/elliotf/5431787


Any ideas?

greelgorke

unread,
Apr 22, 2013, 4:17:32 AM4/22/13
to jad...@googlegroups.com
what you probably want is a mixin https://github.com/visionmedia/jade#a14 

Elliot

unread,
Apr 22, 2013, 2:36:52 PM4/22/13
to jadejs
I'm not sure how I would go about using it, as it appears to have the same problem as using include:

For the list template, it's not a problem, because I can pass the model in to the mixin as an argument.

For the item template, the model *is* the locals.  How do I pass that in to the mixin?

How common is it to use the "self" namespace for locals?  That seems like it would solve the problem (the item template would pass self in as the mixin argument) but then would have "self" all over the place for all of the templates where I don't need it.


--
You received this message because you are subscribed to the Google Groups "Jade" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jadejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

greelgorke

unread,
Apr 23, 2013, 5:16:27 AM4/23/13
to jad...@googlegroups.com
a now i understand. erm yes, it's not that simple. easiest way is never to put the model as context, but to attach it to the context, so items are allways nested (in a list or in the context).

i haven't worked with self yet.
Reply all
Reply to author
Forward
0 new messages