mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 10:12:04 -05:00
parent
751d4906ef
commit
8d695ec592
3 changed files with 13 additions and 1 deletions
|
@ -14,7 +14,7 @@ weight: 10
|
|||
* We now use a custom-built `LazyFileReader` for reading file contents, which means we don't read media files in `/content` into memory anymore -- and file reading is now performed in parallel on multicore PCs. [1181](https://github.com/spf13/hugo/issues/1181)
|
||||
* Hugo is now built with `Go 1.5` which, among many other improvements, have fixed the last known data race in Hugo. [917] (https://github.com/spf13/hugo/issues/917)
|
||||
* Lots of fixes and improvements in the template funcs:
|
||||
* The new `pluralize` template func.
|
||||
* The new `pluralize` and `singularize` template funcs.
|
||||
* The `sort` template func now accepts field/key chaining arguments and pointer values. [1330](https://github.com/spf13/hugo/issues/1330)
|
||||
* Several fixes for `slicestr` and `substr`, most importantly, they now have full `utf-8`-support. [1190](https://github.com/spf13/hugo/issues/1190) [1333](https://github.com/spf13/hugo/issues/1333) [1347](https://github.com/spf13/hugo/issues/1347)
|
||||
* The new `last` template function allows the user to select the last `N` items of a slice. [1148](https://github.com/spf13/hugo/issues/1148)
|
||||
|
|
|
@ -433,6 +433,11 @@ Example: Given `style = "color: red;"` defined in the front matter of your `.md`
|
|||
Note: "ZgotmplZ" is a special value that indicates that unsafe content reached a
|
||||
CSS or URL context.
|
||||
|
||||
### singularize
|
||||
Singularize the given word with a set of common English pluralization rules.
|
||||
|
||||
e.g. `{{ "cats" | singularize }}` → "cat"
|
||||
|
||||
### slicestr
|
||||
|
||||
Slicing in `slicestr` is done by specifying a half-open range with two indices, `start` and `end`.
|
||||
|
|
|
@ -1379,6 +1379,13 @@ func init() {
|
|||
}
|
||||
return inflect.Pluralize(word), nil
|
||||
},
|
||||
"singularize": func(in interface{}) (string, error) {
|
||||
word, err := cast.ToStringE(in)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return inflect.Singularize(word), nil
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue