From a5503e25331e660a4c34ca1f5516f94128af6e8e Mon Sep 17 00:00:00 2001 From: digitalcraftsman Date: Sun, 20 Sep 2015 18:15:45 +0200 Subject: [PATCH] Add template funcs countwords and countrunes --- content/templates/functions.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/content/templates/functions.md b/content/templates/functions.md index 29f265832..350d0782a 100644 --- a/content/templates/functions.md +++ b/content/templates/functions.md @@ -525,6 +525,26 @@ Converts all characters in string to uppercase. e.g. `{{upper "BatMan"}}` β†’ "BATMAN" +### countwords + +`countwords` tries to convert the passed content to a string and counts each word +in it. The template functions works similar to [.WordCount]({{< relref "templates/variables.md#page-variables" >}}). + +```html +{{ "Hugo is a static site generator." | countwords }} + +``` + + +### countrunes + +Alternatively to counting all words , `countrunes` determines the number of runes in the content and excludes any whitespace. This can become useful if you have to deal with +CJK-like languages. + +```html +{{ "Hello, δΈ–η•Œ" | countrunes }} + +``` ## URLs