jeremyruppel / walrus

A bolder kind of mustache
http://documentup.com/jeremyruppel/walrus/
MIT License
215 stars 10 forks source link

:first Walrus Collections filter not working #22

Closed hershmire closed 12 years ago

hershmire commented 12 years ago

The standalone :first filter doesn't seem to be working as expected. In order to get the first object in an array I have to explicitly say :first(1). Below are the two examples that I tried out:

This doesn't work

{{:each imageUrls | :first do}}
<img src="{{thumb}}" />
{{end}}

This works

{{:each imageUrls | :first(1) do}}
<img src="{{thumb}}" />
{{end}}

Here's an example JSON object I'm working with:

"imageUrls": [
   {
    "thumb": "http://someThumbImageURL.jpg",
    "full": "http://someFullImageURL.jpg"
   },
   {
    "thumb": "http://someThumbImageURL.jpg",
    "full": "http://someFullImageURL.jpg"
   },
   {
    "thumb": "http://someThumbImageURL.jpg",
    "full": "http://someFullImageURL.jpg"
   }
]

Not sure if this is the intended use but the README doc shows that simply :first can be utilized so I wanted to bring it to your attention.

jeremyruppel commented 12 years ago

Great catch. This was an issue with :each in general. Fixed on master. NPM is giving me shit while trying to release a new version, so if you need the latest just point at the master branch until I can get this sorted out. Thanks!

jeremyruppel commented 12 years ago

0.7.0 is up on npm.

hershmire commented 12 years ago

Word, thanks dude!