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:
@@ -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)
|
||||
|
||||
31
_examples/view/template_ace_0/main.go
Normal file
31
_examples/view/template_ace_0/main.go
Normal 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")
|
||||
}
|
||||
5
_examples/view/template_ace_0/views/index.ace
Normal file
5
_examples/view/template_ace_0/views/index.ace
Normal file
@@ -0,0 +1,5 @@
|
||||
= include partials/header.ace .
|
||||
|
||||
h2 {{.Title}}
|
||||
|
||||
= include partials/footer.ace .
|
||||
6
_examples/view/template_ace_0/views/layouts/main.ace
Normal file
6
_examples/view/template_ace_0/views/layouts/main.ace
Normal file
@@ -0,0 +1,6 @@
|
||||
= doctype html
|
||||
html
|
||||
head
|
||||
title Main Page
|
||||
body
|
||||
{{ yield }}
|
||||
1
_examples/view/template_ace_0/views/partials/footer.ace
Normal file
1
_examples/view/template_ace_0/views/partials/footer.ace
Normal file
@@ -0,0 +1 @@
|
||||
h1 Partial Footer
|
||||
1
_examples/view/template_ace_0/views/partials/header.ace
Normal file
1
_examples/view/template_ace_0/views/partials/header.ace
Normal file
@@ -0,0 +1 @@
|
||||
h1 Partial Header
|
||||
@@ -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
|
||||
|
||||
@@ -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