How do I loop over the hashes inside the bonsai template?

60 views
Skip to first unread message

Amit Erandole

unread,
Dec 1, 2011, 8:41:53 AM12/1/11
to tiny...@googlegroups.com
Hey ben,

How do I loop over the skills hashes collection that you mention in your documentation?

[code]
   <ul>
{% for skill in {{skills}} %} 
      <li>{{ skill }}</li>
 {% endfor %}
 </ul>
[/code]

This code is just outputting the hashes. How do I get to the values? Not familiar with liquid.

João Figueiredo

unread,
Dec 16, 2011, 1:51:54 PM12/16/11
to Bonsai
Yeah, I have the same question. You should mention that in docs.

João Figueiredo

unread,
Dec 16, 2011, 2:22:47 PM12/16/11
to Bonsai
By the way, I've tried this:
{{#skills}}
{{description}}
{{animal}}
{{/skills}}

But it outputs the following:
descriptionCatanimalAgilitydescriptionBearanimalStrength


On Dec 1, 2:41 pm, Amit Erandole <amit.erand...@gmail.com> wrote:

thisispete

unread,
Jan 30, 2012, 2:20:37 PM1/30/12
to Bonsai
skill is the whole object you can use dot notation to get to the
variables within it like this:

{% for skill in {{skills}} %}
<li>{{ skill.animal }}: {{ skill.description }}</li>
{% endfor %}

shopify has a very helpful page on liquid templating
http://wiki.shopify.com/UsingLiquid


On Dec 16 2011, 11:22 am, João Figueiredo

Ben Schwarz

unread,
Feb 21, 2012, 8:42:31 PM2/21/12
to tiny...@googlegroups.com
Pete, 

Thanks for replying to this. 
If you're able to help me get the bonsai site updated for documentation like this, I'd love to accept your patches. (Or feedback)

Cheers, 

Ben
Reply all
Reply to author
Forward
0 new messages