1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-27 14:57:05 +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

@@ -111,6 +111,7 @@
* [Jet Embedded](view/template_jet_1_embedded)
* [Jet 'urlpath' tmpl func](view/template_jet_2)
* [Jet Template Funcs from Struct](view/template_jet_3)
- [Ace](view/template_ace_0)
* Third-Parties
* [Render `valyala/quicktemplate` templates](view/quicktemplate)
* [Render `shiyanhui/hero` templates](view/herotemplate)

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

View File

@@ -1,3 +1,3 @@
## Info
This folder examines the {{render "dir/templatefilename"}} functionality to manually render any template inside any template
This folder examines the {{render "dir/templatefilename" .}} functionality to manually render any template inside any template

View File

@@ -2,6 +2,6 @@
<h1>Page 1 {{ greet "iris developer"}}</h1>
{{ render "partials/page1_partial1.html"}}
{{ render "partials/page1_partial1.html" }}
</div>