goland iris框架,高手求帮忙 : wrong number of args for render: want 0 got 1

dy2017 2020-05-29 02:13:30
总提示shared/layout.html:10:3: executing "shared/layout.html" at <render>: wrong number of args for render: want 0 got 1
下面是代码main.go

app := iris.New()
//app.Use(recover.New())
//app.Use(iris.LimitRequestBodySize(1024 * 1024))
tmpl := iris.HTML("./views", ".html").
Layout("shared/layout.html").
Reload(true)
app.RegisterView(tmpl)

// registers a handler that serves HTTP requests
// with the contents of a file system (physical or embedded).
app.HandleDir("/content", "./content")

app.OnAnyErrorCode(func(ctx iris.Context) {
ctx.ViewData("Message", ctx.Values().
GetStringDefault("message", "The page you're looking for doesn't exist"))
ctx.View("shared/error.html")
})

//index := app.Party("/", middleware.CrsAuth()).AllowMethods(iris.MethodOptions)
index := mvc.New(app.Party("/"))
index.Handle(new(controller.IndexController))


//app.Get("/",controller.Index)

app.Run(
iris.Addr("localhost:8080"),
// Ignores err server closed log when CTRL/CMD+C pressed.
iris.WithoutServerError(iris.ErrServerClosed),
// Enables faster json serialization and more.
iris.WithOptimizations,
)



type IndexController struct {
Ctx iris.Context
}

var indexView = mvc.View{
Name: "index.html",
//Data: iris.Map{"msg": "Hello Index", "title": "page index",},
}

func (i *IndexController) Get() mvc.Result {
//i.Ctx.ViewLayout(iris.NoLayout)
return indexView
}

func Index(ctx iris.Context) {
//ctx.ViewData("msg", "Hello Index")
//ctx.ViewData("title", "Hello Index")
ctx.View("index.html")
}


layout.html代码

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"/>
<link rel="stylesheet" type="text/css" href="/content/style/site.css"/>
</head>
<body>
{{ render "shared/_top.html"}}
<div>
{{ yield }}
</div>
</body>
</html>


index.html 代码

{{ define "index-title"}}
<title>{{.title}}</title>
{{ end }}
<div style="width: 100%; height: 100%; background-color: #ffffff">
<h1>{{.msg}}}</h1>
</div>


目录结构


提示:
[ERRO] 2020/05/29 02:00 template: shared/layout.html:10:3: executing "shared/layout.html" at <render>: wrong number of args for render: want 0 got 1
高手帮忙解决一下!!
...全文
1008 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dy2017 2020-05-29
  • 打赏
  • 举报
回复 1
新建了相同的工程,没问题了,不知道为啥,奇怪了
dy2017 2020-05-29
  • 打赏
  • 举报
回复 1
IDE:goland求高手帮忙

2,348

社区成员

发帖
与我相关
我的任务
社区描述
go语言学习与交流版
社区管理员
  • go语言社区
  • 俺叫西西弗斯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧