From 18039fcfc0487dc12ebfeb7f40935fe7351486fe Mon Sep 17 00:00:00 2001 From: Zheng-Bote Date: Tue, 15 Apr 2025 17:10:33 +0200 Subject: [PATCH] fix: #52 added render-example -several- with base_s.html, article_s.html, section_s.html --- example/simple/example.go | 6 ++++++ example/simple/templates/article_s.html | 4 ++++ example/simple/templates/base_s.html | 6 ++++++ example/simple/templates/section_s.html | 4 ++++ 4 files changed, 20 insertions(+) create mode 100644 example/simple/templates/article_s.html create mode 100644 example/simple/templates/base_s.html create mode 100644 example/simple/templates/section_s.html diff --git a/example/simple/example.go b/example/simple/example.go index 1e9fb95..641bd56 100644 --- a/example/simple/example.go +++ b/example/simple/example.go @@ -11,6 +11,7 @@ func createMyRender() multitemplate.Renderer { r := multitemplate.NewRenderer() r.AddFromFiles("index", "templates/base.html", "templates/index.html") r.AddFromFiles("article", "templates/base.html", "templates/index.html", "templates/article.html") + r.AddFromFiles("several", "templates/base_s.html", "templates/article_s.html", "templates/section_s.html") return r } @@ -27,6 +28,11 @@ func main() { "title": "Html5 Article Engine", }) }) + router.GET("/several", func(c *gin.Context) { + c.HTML(200, "several", gin.H{ + "title": "Html5 Several Engine", + }) + }) if err := router.Run(":8080"); err != nil { log.Fatal(err) diff --git a/example/simple/templates/article_s.html b/example/simple/templates/article_s.html new file mode 100644 index 0000000..63e5833 --- /dev/null +++ b/example/simple/templates/article_s.html @@ -0,0 +1,4 @@ +{{define "article"}} +

article_s.html

+

Hi, this is article template

+{{end}} diff --git a/example/simple/templates/base_s.html b/example/simple/templates/base_s.html new file mode 100644 index 0000000..8c2e9f8 --- /dev/null +++ b/example/simple/templates/base_s.html @@ -0,0 +1,6 @@ +

base_s.html

+

Title {{ .title }}

+ +
{{template "article" .}}
+ +
{{template "section" .}}
diff --git a/example/simple/templates/section_s.html b/example/simple/templates/section_s.html new file mode 100644 index 0000000..f8f2f26 --- /dev/null +++ b/example/simple/templates/section_s.html @@ -0,0 +1,4 @@ +{{define "section"}} +

section_s.html

+

Hi, this is section template

+{{end}}