Skip to content

View视图

YoyoFx edited this page Dec 9, 2020 · 2 revisions

视图配置

//...
.Configure(func(app *yoyogo.WebApplicationBuilder) {
        app.UseMvc(func(builder *mvc.ControllerBuilder) {
                 builder.AddViews(mvc.ViewOption{Pattern: "Static/templates/**"})
        }
}

hello.tmpl

<h1>{[{.name}]}</h1>

控制器

func (controller UserController) GetHtmlHello() actionresult.IActionResult {
	return controller.View("hello.tmpl", map[string]interface{}{
		"name": "hello world!",
	})
}