ftlabs / fruitmachine

View rendering engine
MIT License
247 stars 18 forks source link

How to refer child slots? #52

Closed sackIndian closed 11 years ago

sackIndian commented 11 years ago

var view = fruitmachine({ module: 'apple', children: [ { slot : 1, module: 'pear', children: { { //here i not defined slot module: 'blackberry', model: model }, { //here i not defined slot module: 'blueberry', model: model } } } ] });

var appleTemp = Hogan.compile('{{{1}}}');

var pearTemp = Hogan.compile('{{{blackberry}}}'); //i am not defined slot:'blackberry' at the child of pear

From pearTemp how can i refer to its childs?

wilsonpage commented 11 years ago

If you want to print all the children in a module's template:

{{#children}}
  {{{child}}}
{{/children}}

Inside the loop you also have access to the child's model:

{{#children}}
  <h2>{{title}}</h2>
  {{{child}}}
{{/children}}

Sounds like you need to read the docs more thoroughly :)

sackIndian commented 11 years ago

Yes @wilsonpage. Thank you very much..

Please let me know if more docs available for Fruitmachine + Hogan.js?