mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Make all renderhook Text methods return template.HTML
This commit is contained in:
@@ -13,8 +13,22 @@
|
||||
|
||||
package hstring
|
||||
|
||||
type RenderedString string
|
||||
import (
|
||||
"html/template"
|
||||
|
||||
func (s RenderedString) String() string {
|
||||
"github.com/gohugoio/hugo/common/types"
|
||||
)
|
||||
|
||||
var _ types.PrintableValueProvider = RenderedHTML("")
|
||||
|
||||
// RenderedHTML is a string that represents rendered HTML.
|
||||
// When printed in templates it will be rendered as template.HTML and considered safe.
|
||||
type RenderedHTML string
|
||||
|
||||
func (s RenderedHTML) String() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
func (s RenderedHTML) PrintableValue() any {
|
||||
return template.HTML(s)
|
||||
}
|
||||
|
@@ -25,6 +25,6 @@ func TestRenderedString(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
// Validate that it will behave like a string in Hugo settings.
|
||||
c.Assert(cast.ToString(RenderedString("Hugo")), qt.Equals, "Hugo")
|
||||
c.Assert(template.HTML(RenderedString("Hugo")), qt.Equals, template.HTML("Hugo"))
|
||||
c.Assert(cast.ToString(RenderedHTML("Hugo")), qt.Equals, "Hugo")
|
||||
c.Assert(template.HTML(RenderedHTML("Hugo")), qt.Equals, template.HTML("Hugo"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user