Thank you @pamubay. You saved the day!
For the following test sample read from using readFile
:
{{- $ret := "<p>{{- $x := 2 -}}\n{{- printf \"Hello World %v\" $x -}}</p>" -}}
You just need to go through something like:
{{- $filename := (printf "deletable-%v-%v" (now.Format "200601021504050700") (crypto.FNV32a $ret)) -}}
{{- $dataList := resources.FromString $filename $ret -}}
{{- $dataList = resources.ExecuteAsTemplate $filename . $dataList -}}
{{- $dataList = string $dataList.Content -}}
Which you get the following printout:
// {{- warnf "DEBUG: '%v'\n" $dataList -}}
DEBUG: '<p>Hello World 2</p>'
Wrap the above into a template function, you’ll get a template capable string sanitiser.