So, I decided to do a replaceRE and pass the matches to a partial. But I’m facing with a weird behavior, when a group match is empty… is always evaluated to true when I use {{with}}
Does anyone know why this could happen? Since replaceRE is limited on the REPLACEMENT argument, I thought that using a partial would make it easier to insert logic… but I’ve spent a lot of time and I’m out of ideas
Any help would be really appreciated.
.RawContent
[[some words|another]]
[[some words]]
[[notes/python/algo]]
[[some words|another]]
[[some words|another]]
single.html
{{ .RawContent | replaceRE `\[\[\s*([^|\]]*)\s*(?:\|\s*([^|\]]*)\s*)?]]` (partial "replaceLink" (dict "Left" "$1" "Right" "$2")) }}
replaceLink.html
{{with .Right}}
{{ printf "%f" . }}
{{end}}
{{with ""}}
nothing
{{end}}
Output
%!f(string=another)
%!f(string=)
%!f(string=)
%!f(string=another)
%!f(string=another)