Splitting a list and adding elements.
Paulo Ferreira <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hello!
I'd like to know if there's a way on Freemarker to divide/split a list.
I have my list full of news, but I'd like to split them in two other lists.
One for 'published' and the other for 'not published'. What I've tried so
far:
[#assign myNodeList = myContent?children?sort_by("news_date")]
[#assign myNodeListPublished = [] ]
[#assign myNodeListNotPublished = [] ]
[#list myNodeList as myNode]
[#if myNode.published == "true"]
//add myNode to myNodeListPublished//
[#else]
/add myNode to myNodeListNotPublished //
[/#if]
[/#list]
Or is there a way that I could assign directly using a filter, just like
this idea:
[#assign myNodeList = myContent?children?sort_by("news_date")]
[#assign myNodeListPublished = myNodeList.where("published" == true) ]
Any ideas ?
Thanks,
Paulo.
--
View this message in context: http://freemarker.624813.n4.nabble.com/Splitting-a-list-and-adding-elements-tp3341910p3341910.html
Sent from the freemarker-user mailing list archive at Nabble.com.
------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d