193
rated 0 times
[
196]
[
3]
/ answers: 1 / hits: 35520
/ 12 Years ago, sat, february 23, 2013, 12:00:00
Here are the resources:
JSON
{
badges:{
unlocked: [
{name: Win 1},
{name: Win 2},
{name: Win 3}
],
locked:[
{name: Lose 1},
{name: Lose 2},
{name: Lose 3}
]
}
}
Algorithm
{{ if_has_badges }}
<div class=badges>
<h1>Badges</h1>
{{ if_has_badges_unlocked }}
<div class=badges-unlocked>
<h2>Unlocked!</h2>
{{ loop_badges_unlocked }}
<a href=# class=badge>
<strong>{{ name }}</strong>
</a>
{{ end_loop_badges_unlocked }}
</div>
{{ end_if_has_badges_unlocked }}
{{ if_has_badges_locked }}
<div class=badges-locked>
<h2>Locked!</h2>
{{ loop_badges_locked }}
<a href=# class=badge>
<strong>{{ name }}</strong>
</a>
{{ end_loop_badges_locked }}
</div>
{{ end_if_has_badges_locked }}
</div>
{{ end_if_has_badges }}
How I can write this algorithm to work with Mustache compiler?
I need to do this to work with two sides, first is the RubyOnRails application and the second is the client-side (JavaScript).
More From » ruby-on-rails