mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-09 15:24:49 +00:00
'sort' template function used to accept only each element's struct field name, method name and map key name as its second argument. This extends it to accept a field/method/key chaining key string like 'Params.foo.bar' as the argument. It evaluates sub elements of each array or map elements and sorts by them. Typical use case would be sorting pages by user defined front matter value. For example, sorting pages by 'Params.foo.bar' is possible by writing the following template code {{ range sort .Data.Pages "Params.foo.bar" }} {{ .Content }} {{ end }} It ignores all leading and trailing dots so "Params.foo.bar" can be written in ".Params.foo.bar" This also fixes the issue that 'sort' cannot evaluate a pointer value. Fix #1330 |
||
---|---|---|
.. | ||
template.go | ||
template_embedded.go | ||
template_funcs.go | ||
template_funcs_test.go | ||
template_resources.go | ||
template_resources_test.go | ||
template_test.go |