{"id":15399475,"url":"https://github.com/chai2010/template","last_synced_at":"2025-10-10T02:49:54.249Z","repository":{"id":77627801,"uuid":"166948103","full_name":"chai2010/template","owner":"chai2010","description":"template helper","archived":false,"fork":false,"pushed_at":"2020-07-05T09:48:45.000Z","size":23,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-04T18:48:40.583Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/chai2010/template","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chai2010.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-22T07:27:49.000Z","updated_at":"2022-10-21T11:02:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"f27703a4-88bb-41b0-b9b9-1a1035df19f7","html_url":"https://github.com/chai2010/template","commit_stats":null,"previous_names":["chai2010/tmpl"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/chai2010/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai2010%2Ftemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai2010%2Ftemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai2010%2Ftemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai2010%2Ftemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chai2010","download_url":"https://codeload.github.com/chai2010/template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai2010%2Ftemplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002551,"owners_count":26083403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T15:49:02.477Z","updated_at":"2025-10-10T02:49:54.219Z","avatar_url":"https://github.com/chai2010.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"- *Go语言QQ群: 102319854, 1055927514*\n- *凹语言(凹读音“Wa”)(The Wa Programming Language): https://github.com/wa-lang/wa*\n\n----\n\n# tmplate helper\n\n[![Build Status](https://travis-ci.org/chai2010/template.svg)](https://travis-ci.org/chai2010/template)\n[![Go Report Card](https://goreportcard.com/badge/github.com/chai2010/template)](https://goreportcard.com/report/github.com/chai2010/template)\n[![GoDoc](https://godoc.org/github.com/chai2010/template?status.svg)](https://godoc.org/github.com/chai2010/template)\n[![License](http://img.shields.io/badge/license-BSD-blue.svg)](https://github.com/chai2010/template/blob/master/LICENSE)\n\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"image\"\n\t\"strings\"\n\n\t\"github.com/chai2010/template\"\n)\n\nfunc main() {\n\tfmt.Println(\n\t\ttemplate.MustRender(`Hello, {{.}}`, \"Neo\"),\n\t)\n\tfmt.Println(\n\t\ttemplate.MustRender(`Hello, {{index . 0}}`, []string{\"Go\"}),\n\t)\n\tfmt.Println(\n\t\ttemplate.MustRender(`Hello, {{index . \"Name\" \"SubName\"}}`,\n\t\t\tmap[string]interface{}{\n\t\t\t\t\"Name\": map[string]string {\n\t\t\t\t\t\"SubName\": \"凹(Wa)\",\n\t\t\t\t},\n\t\t\t},\n\t\t),\n\t)\n\n\tfmt.Println(\n\t\ttemplate.MustRender(`Hello, {{.Name}}`, map[string]string{\n\t\t\t\"Name\": \"Lua\",\n\t\t}),\n\t)\n\tfmt.Println(\n\t\ttemplate.MustRender(`Hello, {{.Name}}`, struct{ Name string }{\n\t\t\tName: \"Ruby\",\n\t\t}),\n\t)\n\n\tfmt.Println(\n\t\ttemplate.MustRender(\n\t\t\t`Hello, {{upper .Name}}, Age: {{Age}}; Point: {{Point.X}}, {{Map.Name.SubName}}`,\n\t\t\tstruct{ Name string }{\n\t\t\t\tName: \"chai2010\",\n\t\t\t},\n\t\t\ttemplate.FuncMap{\n\t\t\t\t\"upper\": strings.ToUpper,\n\t\t\t\t\"Age\":   func() int { return 20 },\n\t\t\t\t\"Point\": func() image.Point { return image.Pt(123, 456) },\n\t\t\t\t\"Map\": func() map[string]interface{} {\n\t\t\t\t\treturn map[string]interface{}{\n\t\t\t\t\t\t\"Name\": struct{ SubName string }{\n\t\t\t\t\t\t\tSubName: \"chai2010\",\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t),\n\t)\n\n\tfmt.Println(\n\t\ttemplate.MustRender(\n\t\t\t`{{range $i, $v := .}}{{$v.Book}}{{end}}`,\n\t\t\t[]struct{ Name, Book string }{\n\t\t\t\t{Name: \"chai2010\", Book: \"《Go语言高级编程》\"},\n\t\t\t\t{Name: \"chai2010 \u0026 ending\", Book: \"《WebAssembly标准入门》\"},\n\t\t\t\t{Name: \"ending \u0026 chai2010\", Book: \"《C/C++面向WebAssembly编程》\"},\n\t\t\t},\n\t\t),\n\t)\n\n\tfmt.Println(\n\t\ttemplate.MustRender(\n\t\t\t`{{range .}}\u003c{{.}}\u003e{{end}}`, []string{\"hello\", \"world\"},\n\t\t),\n\t)\n\n\tfmt.Println(\n\t\ttemplate.MustRenderWithDelims(`Hello, {{\u003c\u003c.))}}`, `\u003c\u003c`, `))`, \"Neo\"),\n\t)\n\n\tfmt.Println(\n\t\ttemplate.MustRender(\n\t\t\t`{{.}}: {{A}}-{{B}}-{{C}}, {{if A}}if A == true{{end}}`,\n\t\t\t\"Self\", template.FuncMap{\n\t\t\t\t\"A\": func() bool { return true },\n\t\t\t\t\"B\": func() int { return 9527 },\n\t\t\t\t\"C\": func() string { return \"C-Value\" },\n\t\t\t},\n\t\t),\n\t)\n\n\tfmt.Println(\n\t\ttemplate.MustRender(\n\t\t\t`slice: {{range $i, $v := slice}}{{$i}}:{{$v}} {{end}}`, nil,\n\t\t\ttemplate.FuncMap{\n\t\t\t\t\"slice\": func() []string {\n\t\t\t\t\treturn []string{\"A\", \"B\", \"C\"}\n\t\t\t\t},\n\t\t\t},\n\t\t),\n\t)\n\n\tfmt.Println(\n\t\ttemplate.MustRenderFile(\"hello.tmpl\", map[string]string{\"Name\": \"World\"}),\n\t)\n\n\t// Output:\n\t// Hello, Neo\n\t// Hello, Go\n\t// Hello, 凹(Wa)\n\t// Hello, Lua\n\t// Hello, Ruby\n\t// Hello, CHAI2010, Age: 20; Point: 123, chai2010\n\t// 《Go语言高级编程》《WebAssembly标准入门》《C/C++面向WebAssembly编程》\n\t// \u003chello\u003e\u003cworld\u003e\n\t// Hello, {{Neo}}\n\t// Self: true-9527-C-Value, if A == true\n\t// slice: 0:A 1:B 2:C\n\t// Hello, World\n}\n```\n\n## BUGS\n\nReport bugs to \u003cchaishushan@gmail.com\u003e.\n\nThanks!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchai2010%2Ftemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchai2010%2Ftemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchai2010%2Ftemplate/lists"}