Re: [mustache] how to render a plain Array
- From:
- Chris Wanstrath
- Date:
- 2010-08-26 @ 00:28
On Tue, Aug 24, 2010 at 12:24 PM, Fernando Guillen
<fguillen.mail@gmail.com> wrote:
> For example:
>
> data = [ 'one', 'two', 'three' ]
>
> View:
> <ul>
> {{#data}}
> <li>{{data}}</li>
> {{/data}}
> </ul>
Either this:
data = [ { :datum => 'one' }, { :datum => 'two' }, { :datum => 'three' } ]
View:
<ul>
{{#data}}
<li>{{datum}}</li>
{{/data}}
</ul>
Or this:
data = [ 'one', 'two', 'three' ]
View:
<ul>
{{#data}}
<li>{{to_s}}</li>
{{/data}}
</ul>
Re: [mustache] how to render a plain Array
- From:
- Fernando Guillen
- Date:
- 2010-08-26 @ 07:11
Hi Chris.
On Thu, Aug 26, 2010 at 2:28 AM, Chris Wanstrath <chris@ozmm.org> wrote:
> Either this:
>
> data = [ { :datum => 'one' }, { :datum => 'two' }, { :datum => 'three' } ]
>
> View:
> <ul>
> {{#data}}
> <li>{{datum}}</li>
> {{/data}}
> </ul>
This is the solution I was using but I didn't understand why I had to
convert a simple Array on something more complex like a Hash just to
render it.
> Or this:
>
> data = [ 'one', 'two', 'three' ]
>
> View:
> <ul>
> {{#data}}
> <li>{{to_s}}</li>
> {{/data}}
> </ul>
I like very much :)
Thanks
f.
--
Fernando Guillén
Freelance Web Developer
http://www.fernandoguillen.info
http://spainrb.org/fernando-guillen