mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
tpl: Add replaceRE function
This commit addes a `replaceRE` template function. Regexp patterns are compiled once and cached.
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
e9008b91fa
commit
b8d3651242
@@ -451,6 +451,13 @@ Replaces all occurrences of the search string with the replacement string.
|
||||
e.g. `{{ replace "Batman and Robin" "Robin" "Catwoman" }}` → "Batman and Catwoman"
|
||||
|
||||
|
||||
### replaceRE
|
||||
Replaces all occurrences of a regular expression with the replacement pattern.
|
||||
|
||||
e.g. `{{ replaceRE "^https?://([^/]+).*" "$1" "http://gohugo.io/docs" }}` → "gohugo.io"
|
||||
e.g. `{{ "http://gohugo.io/docs" | replaceRE "^https?://([^/]+).*" "$1" }}` → "gohugo.io"
|
||||
|
||||
|
||||
### safeHTML
|
||||
Declares the provided string as a "safe" HTML document fragment
|
||||
so Go html/template will not filter it. It should not be used
|
||||
|
Reference in New Issue
Block a user