internal/godoc/dochtml/internal/render: don't use safetemplate alias
github.com/google/safehtml/template no longer uses the safetemplate
alias in internal/godoc/dochtml/internal/render/linkify.go for
consistency in the package, and because it isn't necessary.
Change-Id: I4604c09fd6dca9d804187f395127233e7ed4c4f9
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/261141
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/godoc/dochtml/internal/render/linkify.go b/internal/godoc/dochtml/internal/render/linkify.go
index 34d9604..d5fe7df 100644
--- a/internal/godoc/dochtml/internal/render/linkify.go
+++ b/internal/godoc/dochtml/internal/render/linkify.go
@@ -20,7 +20,7 @@
"github.com/google/safehtml"
"github.com/google/safehtml/legacyconversions"
- safetemplate "github.com/google/safehtml/template"
+ "github.com/google/safehtml/template"
"golang.org/x/pkgsite/internal/godoc/internal/doc"
"golang.org/x/pkgsite/internal/log"
)
@@ -76,7 +76,7 @@
}
// docTmpl renders documentation. It expects a docData.
-var docTmpl = safetemplate.Must(safetemplate.New("").Parse(`
+var docTmpl = template.Must(template.New("").Parse(`
{{- range .Elements -}}
{{- if .IsHeading -}}
<h3 id="{{.ID}}">{{.Title}}
@@ -114,9 +114,9 @@
}
if decl != nil {
out.Decl = safehtml.HTMLConcat(
- safetemplate.MustParseAndExecuteToHTML("<pre>\n"),
+ template.MustParseAndExecuteToHTML("<pre>\n"),
r.formatDeclHTML(decl, idr),
- safetemplate.MustParseAndExecuteToHTML("</pre>\n"))
+ template.MustParseAndExecuteToHTML("</pre>\n"))
}
return out
}
@@ -165,7 +165,7 @@
Comment bool
}
-var codeTmpl = safetemplate.Must(safetemplate.New("").Parse(`
+var codeTmpl = template.Must(template.New("").Parse(`
<pre class="Documentation-exampleCode">
{{range .}}
{{- if .Comment -}}
@@ -322,7 +322,7 @@
return safehtml.HTMLConcat(htmls...)
}
-func ExecuteToHTML(tmpl *safetemplate.Template, data interface{}) safehtml.HTML {
+func ExecuteToHTML(tmpl *template.Template, data interface{}) safehtml.HTML {
h, err := tmpl.ExecuteToHTML(data)
if err != nil {
return safehtml.HTMLEscaped("[" + err.Error() + "]")
@@ -410,9 +410,9 @@
case token.COMMENT:
tokType = commentType
htmlLines[line] = append(htmlLines[line],
- safetemplate.MustParseAndExecuteToHTML(`<span class="comment">`),
+ template.MustParseAndExecuteToHTML(`<span class="comment">`),
r.formatLineHTML(lit, idr),
- safetemplate.MustParseAndExecuteToHTML(`</span>`))
+ template.MustParseAndExecuteToHTML(`</span>`))
lastOffset += len(lit)
case token.IDENT:
if idIdx < len(anchorPoints) && anchorPoints[idIdx].ID.String() != "" {
@@ -462,7 +462,7 @@
return safehtml.HTMLConcat(htmls...)
}
-var anchorTemplate = safetemplate.Must(safetemplate.New("anchor").Parse(`<span id="{{.ID}}" data-kind="{{.Kind}}"></span>`))
+var anchorTemplate = template.Must(template.New("anchor").Parse(`<span id="{{.ID}}" data-kind="{{.Kind}}"></span>`))
// declVisitor is used to walk over the AST and trim large string
// literals and arrays before package documentation is rendered.