mirror of
https://github.com/kataras/iris.git
synced 2025-12-23 12:57:05 +00:00
builtin html template functions changes
This commit is contained in:
@@ -37,10 +37,16 @@ func main() {
|
||||
my := app.Party("/my").Layout("layouts/mylayout.html")
|
||||
{ // both of these will use the layouts/mylayout.html as their layout.
|
||||
my.Get("/", func(ctx iris.Context) {
|
||||
ctx.View("page1.html")
|
||||
if err := ctx.View("page1.html"); err != nil {
|
||||
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||
return
|
||||
}
|
||||
})
|
||||
my.Get("/other", func(ctx iris.Context) {
|
||||
ctx.View("page1.html")
|
||||
if err := ctx.View("page1.html"); err != nil {
|
||||
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
<h1>This is the global layout</h1>
|
||||
<br />
|
||||
<!-- Render the current template here -->
|
||||
{{ yield }}
|
||||
{{ yield . }}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
<h1>This is the layout for the /my/ and /my/other routes only</h1>
|
||||
<br />
|
||||
<!-- Render the current template here -->
|
||||
{{ yield }}
|
||||
{{ yield . }}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
<h1>Page 1 {{ greet "iris developer"}}</h1>
|
||||
|
||||
{{ render "partials/page1_partial1.html"}}
|
||||
{{ render "partials/page1_partial1.html" . }}
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user