{"id":13413843,"url":"https://github.com/valyala/fasttemplate","last_synced_at":"2025-05-14T08:09:38.640Z","repository":{"id":36726593,"uuid":"41033168","full_name":"valyala/fasttemplate","owner":"valyala","description":"Simple and fast template engine for Go","archived":false,"fork":false,"pushed_at":"2023-08-28T10:30:11.000Z","size":36,"stargazers_count":869,"open_issues_count":12,"forks_count":83,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-05-14T00:10:35.437Z","etag":null,"topics":["fast","go","golang","placeholder","template"],"latest_commit_sha":null,"homepage":"","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/valyala.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":"2015-08-19T12:44:22.000Z","updated_at":"2025-05-12T21:36:33.000Z","dependencies_parsed_at":"2024-06-18T11:28:13.956Z","dependency_job_id":null,"html_url":"https://github.com/valyala/fasttemplate","commit_stats":{"total_commits":26,"total_committers":9,"mean_commits":2.888888888888889,"dds":0.3076923076923077,"last_synced_commit":"2a2d1afadadf9715bfa19683cdaeac8347e5d9f9"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valyala%2Ffasttemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valyala%2Ffasttemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valyala%2Ffasttemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valyala%2Ffasttemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/valyala","download_url":"https://codeload.github.com/valyala/fasttemplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101558,"owners_count":22014908,"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":["fast","go","golang","placeholder","template"],"created_at":"2024-07-30T20:01:50.984Z","updated_at":"2025-05-14T08:09:33.632Z","avatar_url":"https://github.com/valyala.png","language":"Go","funding_links":[],"categories":["开源类库","Template Engines","Go","Open source library","模板引擎","\u003cspan id=\"模板引擎-template-engines\"\u003e模板引擎 Template Engines\u003c/span\u003e","模板引擎`模版渲染和模版生成处理库`","Relational Databases"],"sub_categories":["模板引擎","HTTP Clients","Template Engine","Other Software","高級控制台界面","HTTP客户端","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","Advanced Console UIs","交流","查询语","高级控制台界面"],"readme":"fasttemplate\n============\n\nSimple and fast template engine for Go.\n\nFasttemplate performs only a single task - it substitutes template placeholders\nwith user-defined values. At high speed :)\n\nTake a look at [quicktemplate](https://github.com/valyala/quicktemplate) if you  need fast yet powerful html template engine.\n\n*Please note that fasttemplate doesn't do any escaping on template values\nunlike [html/template](http://golang.org/pkg/html/template/) do. So values\nmust be properly escaped before passing them to fasttemplate.*\n\nFasttemplate is faster than [text/template](http://golang.org/pkg/text/template/),\n[strings.Replace](http://golang.org/pkg/strings/#Replace),\n[strings.Replacer](http://golang.org/pkg/strings/#Replacer)\nand [fmt.Fprintf](https://golang.org/pkg/fmt/#Fprintf) on placeholders' substitution.\n\nBelow are benchmark results comparing fasttemplate performance to text/template,\nstrings.Replace, strings.Replacer and fmt.Fprintf:\n\n```\n$ go test -bench=. -benchmem\nPASS\nBenchmarkFmtFprintf-4                   \t 2000000\t       790 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkStringsReplace-4               \t  500000\t      3474 ns/op\t    2112 B/op\t      14 allocs/op\nBenchmarkStringsReplacer-4              \t  500000\t      2657 ns/op\t    2256 B/op\t      23 allocs/op\nBenchmarkTextTemplate-4                 \t  500000\t      3333 ns/op\t     336 B/op\t      19 allocs/op\nBenchmarkFastTemplateExecuteFunc-4      \t 5000000\t       349 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkFastTemplateExecute-4          \t 3000000\t       383 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkFastTemplateExecuteFuncString-4\t 3000000\t       549 ns/op\t     144 B/op\t       1 allocs/op\nBenchmarkFastTemplateExecuteString-4    \t 3000000\t       572 ns/op\t     144 B/op\t       1 allocs/op\nBenchmarkFastTemplateExecuteTagFunc-4   \t 2000000\t       743 ns/op\t     144 B/op\t       3 allocs/op\n```\n\n\nDocs\n====\n\nSee http://godoc.org/github.com/valyala/fasttemplate .\n\n\nUsage\n=====\n\n```go\n\ttemplate := \"http://{{host}}/?q={{query}}\u0026foo={{bar}}{{bar}}\"\n\tt := fasttemplate.New(template, \"{{\", \"}}\")\n\ts := t.ExecuteString(map[string]interface{}{\n\t\t\"host\":  \"google.com\",\n\t\t\"query\": url.QueryEscape(\"hello=world\"),\n\t\t\"bar\":   \"foobar\",\n\t})\n\tfmt.Printf(\"%s\", s)\n\n\t// Output:\n\t// http://google.com/?q=hello%3Dworld\u0026foo=foobarfoobar\n```\n\n\nAdvanced usage\n==============\n\n```go\n\ttemplate := \"Hello, [user]! You won [prize]!!! [foobar]\"\n\tt, err := fasttemplate.NewTemplate(template, \"[\", \"]\")\n\tif err != nil {\n\t\tlog.Fatalf(\"unexpected error when parsing template: %s\", err)\n\t}\n\ts := t.ExecuteFuncString(func(w io.Writer, tag string) (int, error) {\n\t\tswitch tag {\n\t\tcase \"user\":\n\t\t\treturn w.Write([]byte(\"John\"))\n\t\tcase \"prize\":\n\t\t\treturn w.Write([]byte(\"$100500\"))\n\t\tdefault:\n\t\t\treturn w.Write([]byte(fmt.Sprintf(\"[unknown tag %q]\", tag)))\n\t\t}\n\t})\n\tfmt.Printf(\"%s\", s)\n\n\t// Output:\n\t// Hello, John! You won $100500!!! [unknown tag \"foobar\"]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalyala%2Ffasttemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvalyala%2Ffasttemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalyala%2Ffasttemplate/lists"}