Skip to content

Commit 4085c30

Browse files
committed
style: change a method name
1 parent 7bd0244 commit 4085c30

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

context_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ func TestContext_XMLByte(t *testing.T) {
424424
func TestContext_HTML(t *testing.T) {
425425
k := New()
426426
renderer := htmlrenderer.New("testdata/templates/", "layouts/", ".html", false)
427-
renderer.AddFunc("greet", func() int { return 1 })
427+
renderer.SetFunc("greet", func() int { return 1 })
428428
k.htmlRenderer = renderer
429429

430430
ctx := newContext(k)

html_renderer/html.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ func Default(debug bool) *defaultHTMLRenderer {
6161
)
6262
}
6363

64-
// AddFunc adds a function to its func map.
65-
func (r *defaultHTMLRenderer) AddFunc(name string, f any) {
64+
// SetFunc sets a function in the func map.
65+
func (r *defaultHTMLRenderer) SetFunc(name string, f any) {
6666
if f == nil {
6767
panic("function cannot be nil")
6868
}

html_renderer/html_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ func TestDefault(t *testing.T) {
5353
assert.Empty(t, htmlRenderer.templates)
5454
}
5555

56-
func TestDefaultHTMLRenderer_AddFunc(t *testing.T) {
56+
func TestDefaultHTMLRenderer_SetFunc(t *testing.T) {
5757
htmlRenderer := Default(false)
5858

5959
assert.PanicsWithValue(t, "function cannot be nil", func() {
60-
htmlRenderer.AddFunc("func1", nil)
60+
htmlRenderer.SetFunc("func1", nil)
6161
})
6262

63-
htmlRenderer.AddFunc("func1", func() {})
63+
htmlRenderer.SetFunc("func1", func() {})
6464

6565
assert.Equal(t, 1, len(htmlRenderer.funcMap))
6666
}
@@ -103,7 +103,7 @@ func TestDefaultHTMLRenderer_loadTemplates(t *testing.T) {
103103
assert.False(t, htmlRenderer.isInitialized)
104104

105105
htmlRenderer = newTestHTMLRenderer()
106-
htmlRenderer.AddFunc("greet", func(name string) string {
106+
htmlRenderer.SetFunc("greet", func(name string) string {
107107
return "Hello " + name
108108
})
109109

@@ -171,7 +171,7 @@ func TestDefaultHTMLRenderer_RenderHTML(t *testing.T) {
171171
})
172172

173173
htmlRenderer = newTestHTMLRenderer()
174-
htmlRenderer.AddFunc("greet", func(name string) string {
174+
htmlRenderer.SetFunc("greet", func(name string) string {
175175
return "Hello " + name
176176
})
177177

0 commit comments

Comments
 (0)