hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

complement.md (893B)

    1 ---
    2 title: "complement"
    3 description: "`collections.Complement` (alias `complement`) gives the elements of a collection that are not in any of the others."
    4 date: 2018-11-07
    5 categories: [functions]
    6 menu:
    7   docs:
    8     parent: "functions"
    9 keywords: [collections,intersect,union]
   10 signature: ["COLLECTION | complement COLLECTION [COLLECTION]..." ]
   11 hugoversion: "0.51"
   12 aliases: []
   13 ---
   14 
   15 Example:
   16 
   17 ```go-html-template
   18 {{ $pages := site.RegularPages | first 50 }}
   19 {{ $news := where $pages "Type" "news" | first 5 }}
   20 {{ $blog := where $pages "Type" "blog" | first 5 }}
   21 {{ $other := $pages | complement $news $blog | first 10 }}
   22 ```
   23 
   24 The above is an imaginary use case for the home page where you want to display different page listings in sections/boxes on different places on the page: 5 from `news`, 5 from the `blog` and then 10 of the pages not shown in the other listings, to _complement_ them.
   25 
   26 
   27 
   28 
   29