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

Function Test_Ctx_RenderWithLocalsAndBinding

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

Source from the content-addressed store, hash-verified

7864}
7865
7866func Test_Ctx_RenderWithLocalsAndBinding(t *testing.T) {
7867 t.Parallel()
7868 engine := &testTemplateEngine{}
7869 err := engine.Load()
7870 require.NoError(t, err)
7871
7872 app := New(Config{
7873 PassLocalsToViews: true,
7874 Views: engine,
7875 })
7876 c := app.AcquireCtx(&fasthttp.RequestCtx{})
7877
7878 c.Locals("Title", "This is a test.")
7879
7880 err = c.Render("index.tmpl", Map{
7881 "Title": "Hello, World!",
7882 })
7883
7884 require.NoError(t, err)
7885 require.Equal(t, "<h1>Hello, World!</h1>", string(c.Response().Body()))
7886}
7887
7888func Benchmark_Ctx_RenderWithLocalsAndViewBind(b *testing.B) {
7889 engine := &testTemplateEngine{}

Callers

nothing calls this directly

Calls 7

LoadMethod · 0.95
AcquireCtxMethod · 0.80
NewFunction · 0.70
LocalsMethod · 0.65
RenderMethod · 0.65
BodyMethod · 0.65
ResponseMethod · 0.65

Tested by

no test coverage detected