Slice child pages in collection

Hi!

How can I slice child pages in collection few times on page??

For example, on homepage i want to show first 2 posts in one style, then next 5 posts in other styles and after that all other posts (8, 9, 10 etc).

I try something like

{% for child in collection.slice(0, 2) %}
   {% include 'partials/blog_item.html.twig' with {'page':child, 'truncate':true} %}
{% endfor %} 

and after that

{% for child in collection.slice(2, 5) %}
   {% include 'partials/blog_item.html.twig' with {'page':child, 'truncate':true} %}
{% endfor %} 

but second block shows nothing…

Thaks!

I think you are trying to use the slice filter? If so it’s not .slice(0, 2) it’s |slice(0, 2)

http://twig.sensiolabs.org/doc/filters/slice.html

Thats it! So simple…
Thanks rhukster!