{"id":13413842,"url":"https://github.com/dannyvankooten/extemplate","last_synced_at":"2025-03-14T20:30:42.681Z","repository":{"id":55999489,"uuid":"144329837","full_name":"dannyvankooten/extemplate","owner":"dannyvankooten","description":"Wrapper package for Go's template/html to allow for easy file-based template inheritance.","archived":true,"fork":false,"pushed_at":"2022-12-06T12:37:35.000Z","size":37,"stargazers_count":60,"open_issues_count":1,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-08T01:03:53.692Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://git.sr.ht/~dvko/extemplate","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dannyvankooten.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}},"created_at":"2018-08-10T20:34:19.000Z","updated_at":"2025-02-17T01:43:56.000Z","dependencies_parsed_at":"2023-01-24T01:45:08.012Z","dependency_job_id":null,"html_url":"https://github.com/dannyvankooten/extemplate","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannyvankooten%2Fextemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannyvankooten%2Fextemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannyvankooten%2Fextemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannyvankooten%2Fextemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dannyvankooten","download_url":"https://codeload.github.com/dannyvankooten/extemplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243641964,"owners_count":20323940,"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","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-07-30T20:01:50.954Z","updated_at":"2025-03-14T20:30:42.390Z","avatar_url":"https://github.com/dannyvankooten.png","language":"Go","funding_links":[],"categories":["模板引擎","Template Engines","模板引擎`模版渲染和模版生成处理库`","Relational Databases"],"sub_categories":["交流","HTTP客户端","HTTP Clients","查询语"],"readme":"This repository moved to https://git.sr.ht/~dvko/extemplate on 2022-12-06 :warning:\n\n---\n\n# Extemplate [![GoDoc](http://godoc.org/github.com/dannyvankooten/extemplate?status.svg)](http://godoc.org/github.com/dannyvankooten/extemplate)  [![Build Status](https://travis-ci.org/dannyvankooten/extemplate.svg)](https://travis-ci.org/dannyvankooten/extemplate) [![Go Report Card](https://goreportcard.com/badge/github.com/dannyvankooten/extemplate)](https://goreportcard.com/report/github.com/dannyvankooten/extemplate) [![Coverage](https://gocover.io/_badge/github.com/dannyvankooten/extemplate)](https://gocover.io/github.com/dannyvankooten/extemplate)\n\nExtemplate is a small wrapper package around [html/template](https://golang.org/pkg/html/template/) to allow for easy file-based template inheritance.\n\nFile: `templates/parent.tmpl`\n```text\n\u003chtml\u003e\n\u003chead\u003e\n\t\u003ctitle\u003e{{ block \"title\" }}Default title{{ end }}\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\t{{ block \"content\" }}Default content{{ end }} \n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nFile: `templates/child.tmpl`\n```text\n{{ extends \"parent.tmpl\" }}\n{{ define \"title\" }}Child title{{ end }}\n{{ define \"content\" }}Hello world!{{ end }}\n```\n\nFile: `main.go`\n```go\nxt := extemplate.New()\nxt.ParseDir(\"templates/\", []string{\".tmpl\"})\n_ = xt.ExecuteTemplate(os.Stdout, \"child.tmpl\", \"no data needed\") \n// Output: \u003chtml\u003e.... Hello world! ....\u003c/html\u003e\n```\n\nExtemplate recursively walks all files in the given directory and will parse the files matching the given extensions as a template. Templates are named by path and filename, relative to the root directory.\n\nFor example, calling `ParseDir(\"templates/\", []string{\".tmpl\"})` on the following directory structure:\n\n```text\ntemplates/\n  |__ admin/\n  |      |__ index.tmpl\n  |      |__ edit.tmpl\n  |__ index.tmpl\n```\n\nWill result in the following templates:\n\n```text\nadmin/index.tmpl\nadmin/edit.tmpl\nindex.tmpl\n```\n\nCheck out the [tests](https://github.com/dannyvankooten/extemplate/blob/master/template_test.go) and [examples directory](https://github.com/dannyvankooten/extemplate/tree/master/examples) for more examples.\n\n### Benchmarks\n\nYou will most likely never have to worry about performance, when using this package properly. \nThe benchmarks are purely listed here so we have a place to keep track of progress.\n\n```\nBenchmarkExtemplateGetLayoutForTemplate-8   \t 2000000\t       923 ns/op\t     104 B/op\t       3 allocs/op\nBenchmarkExtemplateParseDir-8               \t    5000\t    227898 ns/op\t   34864 B/op\t     325 allocs/op\n```\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyvankooten%2Fextemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdannyvankooten%2Fextemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyvankooten%2Fextemplate/lists"}