Comment on sortPosts behaviour
This commit is contained in:
parent
cf65fcc5c3
commit
ae794d9d59
1 changed files with 3 additions and 0 deletions
|
@ -43,6 +43,9 @@ func mustParseTmpl(name, value string) *template.Template {
|
|||
var funcMap template.FuncMap = template.FuncMap{
|
||||
// sorts posts by date, newest posts go first
|
||||
"sortPosts": func(posts []*post) []*post {
|
||||
// sortPosts is most likely to be used in a pipeline, and the
|
||||
// user has every right to expect it doesn't modify their
|
||||
// existing posts slice
|
||||
ps := make(postsSort, len(posts))
|
||||
copy(ps, posts)
|
||||
sort.Sort(ps)
|
||||
|
|
Loading…
Reference in a new issue