MCPcopy
hub / github.com/gofiber/fiber / Test_Ctx_RenderWithViewBindLocals

Function Test_Ctx_RenderWithViewBindLocals

ctx_test.go:7844–7864  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7842}
7843
7844func Test_Ctx_RenderWithViewBindLocals(t *testing.T) {
7845 t.Parallel()
7846 app := New(Config{
7847 PassLocalsToViews: true,
7848 })
7849
7850 c := app.AcquireCtx(&fasthttp.RequestCtx{})
7851
7852 err := c.ViewBind(Map{
7853 "Title": "Hello, World!",
7854 })
7855 require.NoError(t, err)
7856
7857 c.Locals("Summary", "Test")
7858
7859 err = c.Render("./.github/testdata/template.tmpl", Map{})
7860 require.NoError(t, err)
7861 require.Equal(t, "<h1>Hello, World! Test</h1>", string(c.Response().Body()))
7862
7863 require.Equal(t, "<h1>Hello, World! Test</h1>", string(c.Response().Body()))
7864}
7865
7866func Test_Ctx_RenderWithLocalsAndBinding(t *testing.T) {
7867 t.Parallel()

Callers

nothing calls this directly

Calls 7

AcquireCtxMethod · 0.80
NewFunction · 0.70
ViewBindMethod · 0.65
LocalsMethod · 0.65
RenderMethod · 0.65
BodyMethod · 0.65
ResponseMethod · 0.65

Tested by

no test coverage detected