1
0
mirror of https://github.com/golang/go synced 2024-11-11 18:21:40 -07:00

html/template: use maps.Copy in escaper.escapeListConditionally

To make it a little simpler.

Change-Id: Id3c6b0b2570558be396017b8fc877481b79ef837
This commit is contained in:
Jes Cok 2024-09-11 23:33:47 +08:00
parent 9deda35ff8
commit 2eae47fe8b

View File

@ -10,6 +10,7 @@ import (
"html"
"internal/godebug"
"io"
"maps"
"regexp"
"text/template"
"text/template/parse"
@ -588,22 +589,14 @@ func (e *escaper) escapeListConditionally(c context, n *parse.ListNode, filter f
e1 := makeEscaper(e.ns)
e1.rangeContext = e.rangeContext
// Make type inferences available to f.
for k, v := range e.output {
e1.output[k] = v
}
maps.Copy(e1.output, e.output)
c = e1.escapeList(c, n)
ok := filter != nil && filter(&e1, c)
if ok {
// Copy inferences and edits from e1 back into e.
for k, v := range e1.output {
e.output[k] = v
}
for k, v := range e1.derived {
e.derived[k] = v
}
for k, v := range e1.called {
e.called[k] = v
}
maps.Copy(e.output, e1.output)
maps.Copy(e.derived, e1.derived)
maps.Copy(e.called, e1.called)
for k, v := range e1.actionNodeEdits {
e.editActionNode(k, v)
}