Is OR in {{ range }} possible?

Hi,

i’d like to do something like this:

{{ range first 5 .Site.Taxonomies.tags.(news OR gossips) }}
    {{ .Page.Title }}
{{ end }}

This of course does not work. So, is there a way of ‘ranging’ through tags to pick pages that have EITHER ‘news’ OR ‘gossips’ in their ‘tags’?

Thanks.

See the where clause and combine that with slice and in.

See

You would want to drop the Paginate part (probably).

Come to think of it, where may not work with maps … @moorereason may know.

Could that be done using comparison operators?

This does not work:

{{ range first 1 (if or (eq .Site.Taxonomies.tags “news”) (eq .Site.Taxonomies.tags “gossips”) ) }}

// somethind

{{ end }}

where won’t currently iterate over maps. I have a PR pending that provides basic support for it.

https://github.com/spf13/hugo/pull/2076