Skip to content

Commit

Permalink
Improvement to docs (Keats#698)
Browse files Browse the repository at this point in the history
* Docs : Clarify `addslashes` filter
* Docs : Clarify `slugify` filter
* Docs : Clarify `trim_start_matches` & `trim_end_matches` filters
  • Loading branch information
rootkea committed Jan 6, 2022
1 parent 3f48bd2 commit 903d2a2
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions docs/content/docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -789,21 +789,20 @@ the `from` string replaced with the `to` string.
Example: `{{ name | replace(from="Robert", to="Bob")}}`

#### addslashes
Adds slashes before quotes.
Adds slashes before single quote (`'`), double quote (`"`) and slash (`\`) chars.

Example: `{{ value | addslashes }}`

If value is "I'm using Tera", the output will be "I\\'m using Tera".
If value is \`Alice said, "I'm using \\ in Tera"\`, the output will be \`Alice said, \\"I\\'m using \\\\ in Tera\\"\`.

#### slugify
Only available if the `builtins` feature is enabled.

Transforms a string into ASCII, lowercases it, trims it, converts spaces to hyphens and
removes all characters that are not numbers, lowercase letters or hyphens.
Transforms a string into ASCII, lowercases it, trims it, converts all characters that are not numbers or lowercase letters to hyphens, replaces continuous sequence of hyphens with a single hyphen and removes leading and trailing hyphens if any.

Example: `{{ value | slugify }}`

If value is "-Hello world! ", the output will be "hello-world".
If value is " -This-- Is तेरा! ", the output will be "this-is-teraa".

#### title
Capitalizes each word inside a sentence.
Expand All @@ -822,16 +821,16 @@ Removes leading whitespace if the variable is a string.
Removes trailing whitespace if the variable is a string.

#### trim_start_matches
Removes leading characters that match the given pattern if the variable is a string.
Repeatedly removes leading characters that match the given pattern if the variable is a string.

Example: `{{ value | trim_start_matches(pat="//") }}`
Example: `{{ value | trim_start_matches(pat="/") }}`

If value is "//a/b/c//", the output will be "a/b/c//".

#### trim_end_matches
Removes trailing characters that match the given pattern if the variable is a string.
Repeatedly removes trailing characters that match the given pattern if the variable is a string.

Example: `{{ value | trim_end_matches(pat="//") }}`
Example: `{{ value | trim_end_matches(pat="/") }}`

If value is "//a/b/c//", the output will be "//a/b/c".

Expand Down

0 comments on commit 903d2a2

Please sign in to comment.