golang iris直接返回模板html

golang iris直接返回模板html,go,Go,我想直接返回模板html。在func(c*HelloController)Get()mvc.View{return helloView}中,但一旦执行此操作,模板中的参数将为空。{{.Title}和{.MyMessage}丢失以下是我的结果,如预期的那样: 我能帮你做点什么吗?你说的“直接返回”是什么意思?还有:不要使用iris.means直接返回。我想要的结果是{.Title}-My-App{.MyMessage}但是实际结果-My-App为什么不使用Iris@chaoshook以下是一些搜

我想直接返回模板html。在func(c*HelloController)Get()mvc.View{return helloView}中,但一旦执行此操作,模板中的参数将为空。{{.Title}和{.MyMessage}丢失

以下是我的结果,如预期的那样:


我能帮你做点什么吗?

你说的“直接返回”是什么意思?还有:不要使用iris.means直接返回。我想要的结果是{.Title}-My-App{.MyMessage}

但是实际结果-My-App

为什么不使用Iris@chaoshook以下是一些搜索结果,以明确您可能希望避开Iris的原因:
<!-- file: web/views/hello/index.html -->
<html>
<head>
    <title>{{.Title}} - My App</title>
</head>
<body>
    <p>{{.MyMessage}}</p>
</body>
</html>
package main

import (
  "github.com/kataras/iris"
)
func main() {
    app := iris.New()
    // Load the template files.
    app.RegisterView(iris.HTML("./web/views", ".html"))
    // Serve our controllers.
    mvc.New(app.Party("/hello")).Handle(new(controllers.HelloController))
    // http://localhost:8080/hello
    app.Run(
        iris.Addr("localhost:8080"),
        iris.WithoutVersionChecker,
        iris.WithoutServerError(iris.ErrServerClosed),
        iris.WithOptimizations,
    )
}
package controllers

import (
    "github.com/kataras/iris/mvc"
)
type HelloController struct{}

var helloView = mvc.View{
    Name: "hello/index.html",
    Data: map[string]interface{}{
        "Title":     "Hello Page",
        //"MyMessage": "Welcome to my awesome website",
    },
}
func (c *HelloController) Get() mvc.Result {
    return helloView
}