Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Dec 20, 2016
1 parent 2095b85 commit 5196daa
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -38,8 +38,8 @@ import (

func createMyRender() multitemplate.Render {
r := multitemplate.New()
r.AddFromFiles("index", "templates/base.html", "templates/base.html")
r.AddFromFiles("article", "templates/base.html", "templates/article.html")
r.AddFromFiles("index", "templates/base.html", "templates/index.html")
r.AddFromFiles("article", "templates/base.html", "templates/index.html", "templates/article.html")

return r
}
Expand All @@ -53,7 +53,7 @@ func main() {
})
})
router.GET("/article", func(c *gin.Context) {
c.HTML(200, "index", gin.H{
c.HTML(200, "article", gin.H{
"title": "Html5 Article Engine",
})
})
Expand Down
7 changes: 4 additions & 3 deletions example/example.go
Expand Up @@ -8,8 +8,9 @@ import (

func createMyRender() multitemplate.Render {
r := multitemplate.New()
r.AddFromFiles("index", "templates/base.html", "templates/base.html")
r.AddFromFiles("article", "templates/base.html", "templates/article.html")
r.AddFromFiles("index", "templates/base.html", "templates/index.html")
r.AddFromFiles("article", "templates/base.html", "templates/index.html", "templates/article.html")

// r.AddFromFiles("login", "base.html", "login.html")
// r.AddFromFiles("dashboard", "base.html", "dashboard.html")

Expand All @@ -25,7 +26,7 @@ func main() {
})
})
router.GET("/article", func(c *gin.Context) {
c.HTML(200, "index", gin.H{
c.HTML(200, "article", gin.H{
"title": "Html5 Article Engine",
})
})
Expand Down
2 changes: 1 addition & 1 deletion example/templates/article.html
@@ -1 +1 @@
Welcome to {{ .title }}
{{define "article.html"}}Hi, this is article template{{end}}
4 changes: 3 additions & 1 deletion example/templates/base.html
@@ -1 +1,3 @@
Welcome to {{ .title }}
Title: {{ .title }}

index template: {{template "index.html"}}
1 change: 1 addition & 0 deletions example/templates/index.html
@@ -0,0 +1 @@
Hi, this is index.html

0 comments on commit 5196daa

Please sign in to comment.