mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
9b0050e9aa
git-subtree-dir: docs git-subtree-split: 5c085a37b297bf12f59efeaae591418ec025c10d
1.1 KiB
1.1 KiB
title | description | categories | keywords | action | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PlainWords | Calls the Plain method, splits the result into a slice of words, and returns the slice. |
|
The PlainWords
method on a Page
object calls the Plain
method, then uses Go's strings.Fields
function to split the result into words.
{{% note %}}
Fields splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace
, returning a slice of substrings of s or an empty slice if s contains only white space.
{{% /note %}}
As a result, elements within the slice may contain leading or trailing punctuation.
{{ .PlainWords }}
To determine the approximate number of unique words on a page:
{{ .PlainWords | uniq }} → 42