colinta / StrangeCase

It's yet another static site generator. Have you seen jekyll? hyde? Yup. Like those.
http://colinta.com/projects/StrangeCase.html
Other
49 stars 7 forks source link

how do i pick the 3 most recent news items from a folder? #27

Closed sureshvv closed 12 years ago

sureshvv commented 12 years ago

I can see how I would pick all of them. But how do I pick just the top 3?

colinta commented 12 years ago

jinja2 is powerful enough to do this using good ol' python slicing, but I hadn't tried it until now! v4.5.10 - just pushed - supports slices.

{% for news in site.news[0:3] %}
...
{% endfor %}
sureshvv commented 12 years ago

Awesome!

colinta commented 12 years ago

In looking at the other issue you're having, #29, I realized that site.news[0:3] will give the three oldest news items.

site.news[-3:] is what we want here, I think.