diff options
author | Joe Mooring <joe.mooring@veriphor.com> | 2022-12-03 17:06:56 -0800 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-12-04 09:25:51 +0100 |
commit | 0b976d2b40fb3bc590f1cb01515116376bac0003 (patch) | |
tree | d79162f026e4aca01e1a0270c8d10771ccca3dbf /tpl/tplimpl/template.go | |
parent | a49e51fd0b03c261358643fb6656257158d95520 (diff) |
tpl/tplimpl: Allow alternate comment syntax
Allow alternate comment syntax before block definitions:
{{/* foo */}}
{{- /* foo */}}
{{- /* foo */ -}}
Fixes #10495
Diffstat (limited to 'tpl/tplimpl/template.go')
-rw-r--r-- | tpl/tplimpl/template.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tpl/tplimpl/template.go b/tpl/tplimpl/template.go index 81c898b2f..9a9e82a80 100644 --- a/tpl/tplimpl/template.go +++ b/tpl/tplimpl/template.go @@ -91,9 +91,15 @@ func needsBaseTemplate(templ string) bool { if !inComment && strings.HasPrefix(templ[i:], "{{/*") { inComment = true i += 4 + } else if !inComment && strings.HasPrefix(templ[i:], "{{- /*") { + inComment = true + i += 6 } else if inComment && strings.HasPrefix(templ[i:], "*/}}") { inComment = false i += 4 + } else if inComment && strings.HasPrefix(templ[i:], "*/ -}}") { + inComment = false + i += 6 } else { r, size := utf8.DecodeRuneInString(templ[i:]) if !inComment { |