| 7864 | } |
| 7865 | |
| 7866 | func 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 | |
| 7888 | func Benchmark_Ctx_RenderWithLocalsAndViewBind(b *testing.B) { |
| 7889 | engine := &testTemplateEngine{} |