Skip to content

Commit 6844be5

Browse files
committed
add 'iris.Ace' template engine: _examples/view/template_ace_0
1 parent dfa0804 commit 6844be5

File tree

20 files changed

+197
-52
lines changed

20 files changed

+197
-52
lines changed

HISTORY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ Response:
359359

360360
Other Improvements:
361361

362+
- Add [Ace](_examples/view/template_ace_0) template parser to the view engine and other minor improvements. <!-- a new html/template-based engine, with a different layout-page syntax but better performance, follows this week. -->
363+
362364
- Fix huge repo size of 55.7MB, which slows down the overall Iris installation experience. Now, go-get performs ~3 times faster. I 've managed it using the [bfg-repo-cleaner](https://github.com/rtyley/bfg-repo-cleaner) tool - an alternative to git-filter-branch command. Watch the small gif below to learn how:
363365

364366
[![](https://media.giphy.com/media/U8560aiWTurW4iAOLn/giphy.gif)](https://media.giphy.com/media/U8560aiWTurW4iAOLn/giphy.gif)

NOTICE

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ Revision ID: d1c07411df0bb21f6b21f5b5d9325fac6f29c911
1010

1111
----------------- ----------------- ------------------------------------------
1212
Package Version Website
13-
----------------- ----------------- ------------------------------------------
13+
----------------- ----------------- ------------------------------------------
14+
ace ea038f4770b6746 https://github.com/yosssi/ace
15+
c3f8f84f14fa60d
16+
9fe1205b56
1417
badger 536fed1846d0f4d https://github.com/dgraph-io/badger
1518
b9579bcff679761
1619
4e134eadfa

_examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
* [Jet Embedded](view/template_jet_1_embedded)
112112
* [Jet 'urlpath' tmpl func](view/template_jet_2)
113113
* [Jet Template Funcs from Struct](view/template_jet_3)
114+
- [Ace](view/template_ace_0)
114115
* Third-Parties
115116
* [Render `valyala/quicktemplate` templates](view/quicktemplate)
116117
* [Render `shiyanhui/hero` templates](view/herotemplate)

_examples/view/template_ace_0/main.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package main
2+
3+
import "github.com/kataras/iris/v12"
4+
5+
func main() {
6+
app := iris.New()
7+
8+
// Read about its markup syntax at: https://github.com/yosssi/ace
9+
tmpl := iris.Ace("./views", ".ace")
10+
// tmpl.Layout("layouts/main.ace") -> global layout for all pages.
11+
12+
app.RegisterView(tmpl)
13+
14+
app.Get("/", func(ctx iris.Context) {
15+
ctx.View("index.ace", iris.Map{
16+
"Title": "Title of The Page",
17+
})
18+
})
19+
20+
app.Get("/layout", func(ctx iris.Context) {
21+
ctx.ViewLayout("layouts/main.ace") // layout for that response.
22+
ctx.View("index.ace", iris.Map{
23+
"Title": "Title of the main Page",
24+
})
25+
})
26+
27+
// otherGroup := app.Party("/other").Layout("layouts/other.ace") -> layout for that party.
28+
// otherGroup.Get("/", func(ctx iris.Context) { ctx.View("index.ace", [...]) })
29+
30+
app.Listen(":8080")
31+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
= include partials/header.ace .
2+
3+
h2 {{.Title}}
4+
5+
= include partials/footer.ace .
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
= doctype html
2+
html
3+
head
4+
title Main Page
5+
body
6+
{{ yield }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
h1 Partial Footer
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
h1 Partial Header
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## Info
22

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

_examples/view/template_html_2/templates/page1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
<h1>Page 1 {{ greet "iris developer"}}</h1>
44

5-
{{ render "partials/page1_partial1.html"}}
5+
{{ render "partials/page1_partial1.html" }}
66

77
</div>

0 commit comments

Comments
 (0)