1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 13:05:56 +00:00

add 'iris.Ace' template engine: _examples/view/template_ace_0

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-03 05:46:04 +03:00
parent dfa08041a1
commit 6844be57ea
20 changed files with 197 additions and 52 deletions

View File

@@ -0,0 +1,31 @@
package main
import "github.com/kataras/iris/v12"
func main() {
app := iris.New()
// Read about its markup syntax at: https://github.com/yosssi/ace
tmpl := iris.Ace("./views", ".ace")
// tmpl.Layout("layouts/main.ace") -> global layout for all pages.
app.RegisterView(tmpl)
app.Get("/", func(ctx iris.Context) {
ctx.View("index.ace", iris.Map{
"Title": "Title of The Page",
})
})
app.Get("/layout", func(ctx iris.Context) {
ctx.ViewLayout("layouts/main.ace") // layout for that response.
ctx.View("index.ace", iris.Map{
"Title": "Title of the main Page",
})
})
// otherGroup := app.Party("/other").Layout("layouts/other.ace") -> layout for that party.
// otherGroup.Get("/", func(ctx iris.Context) { ctx.View("index.ace", [...]) })
app.Listen(":8080")
}

View File

@@ -0,0 +1,5 @@
= include partials/header.ace .
h2 {{.Title}}
= include partials/footer.ace .

View File

@@ -0,0 +1,6 @@
= doctype html
html
head
title Main Page
body
{{ yield }}

View File

@@ -0,0 +1 @@
h1 Partial Footer

View File

@@ -0,0 +1 @@
h1 Partial Header