Skip to content

Commit

Permalink
Fix same RegisterView engine of html suffix, show error bug.
Browse files Browse the repository at this point in the history
Now edit to will not repeat ~!
  • Loading branch information
23233 committed May 7, 2020
1 parent f914d5c commit b60890a
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 81 deletions.
9 changes: 9 additions & 0 deletions _examples/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ func main() {
panic(err)
}

//more RegisterView
tmpl := iris.HTML("./templates", ".html").Layout("layout.html")
tmpl.Reload(true) // reload templates on each request (development mode)
app.RegisterView(tmpl)

app.Get("/", func(ctx iris.Context) {
_ = ctx.View("index.html")
})

_ = app.Listen(":8080")

}
10 changes: 10 additions & 0 deletions _examples/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
123123
</body>
</html>
12 changes: 12 additions & 0 deletions _examples/templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>Title</title>
</head>
<body>
<h1>[layout] Body content is below...</h1>
{{ yield }}
</body>
</html>
Loading

0 comments on commit b60890a

Please sign in to comment.