{"id":17856821,"url":"https://github.com/masterminds/sprig","last_synced_at":"2025-09-09T21:21:59.887Z","repository":{"id":37270231,"uuid":"14605416","full_name":"Masterminds/sprig","owner":"Masterminds","description":"Useful template functions for Go templates.","archived":false,"fork":false,"pushed_at":"2024-10-28T11:50:27.000Z","size":573,"stargazers_count":4463,"open_issues_count":153,"forks_count":461,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-05-06T19:51:51.855Z","etag":null,"topics":["go","template","templates"],"latest_commit_sha":null,"homepage":"http://masterminds.github.io/sprig/","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/Masterminds.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2013-11-22T01:20:40.000Z","updated_at":"2025-05-06T05:10:50.000Z","dependencies_parsed_at":"2023-02-19T17:25:26.205Z","dependency_job_id":"dea99745-202f-4299-8413-f55800710e35","html_url":"https://github.com/Masterminds/sprig","commit_stats":{"total_commits":322,"total_committers":107,"mean_commits":"3.0093457943925235","dds":0.8167701863354038,"last_synced_commit":"8cb06fe3c8b0f1163c26b0a558669da72ee14656"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masterminds%2Fsprig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masterminds%2Fsprig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masterminds%2Fsprig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masterminds%2Fsprig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Masterminds","download_url":"https://codeload.github.com/Masterminds/sprig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020473,"owners_count":22000750,"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":["go","template","templates"],"created_at":"2024-10-28T03:09:28.495Z","updated_at":"2025-05-13T20:03:07.232Z","avatar_url":"https://github.com/Masterminds.png","language":"Go","readme":"# Sprig: Template functions for Go templates\n\n[![GoDoc](https://img.shields.io/static/v1?label=godoc\u0026message=reference\u0026color=blue)](https://pkg.go.dev/github.com/Masterminds/sprig/v3)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Masterminds/sprig)](https://goreportcard.com/report/github.com/Masterminds/sprig)\n[![Stability: Sustained](https://masterminds.github.io/stability/sustained.svg)](https://masterminds.github.io/stability/sustained.html)\n[![](https://github.com/Masterminds/sprig/workflows/Tests/badge.svg)](https://github.com/Masterminds/sprig/actions)\n\nThe Go language comes with a [built-in template\nlanguage](http://golang.org/pkg/text/template/), but not\nvery many template functions. Sprig is a library that provides more than 100 commonly\nused template functions.\n\nIt is inspired by the template functions found in\n[Twig](http://twig.sensiolabs.org/documentation) and in various\nJavaScript libraries, such as [underscore.js](http://underscorejs.org/).\n\n## IMPORTANT NOTES\n\nSprig leverages [mergo](https://github.com/imdario/mergo) to handle merges. In\nits v0.3.9 release, there was a behavior change that impacts merging template\nfunctions in sprig. It is currently recommended to use v0.3.10 or later of that package.\nUsing v0.3.9 will cause sprig tests to fail.\n\n## Package Versions\n\nThere are two active major versions of the `sprig` package.\n\n* v3 is currently stable release series on the `master` branch. The Go API should\n  remain compatible with v2, the current stable version. Behavior change behind\n  some functions is the reason for the new major version.\n* v2 is the previous stable release series. It has been more than three years since\n  the initial release of v2. You can read the documentation and see the code\n  on the [release-2](https://github.com/Masterminds/sprig/tree/release-2) branch.\n  Bug fixes to this major version will continue for some time.\n\n## Usage\n\n**Template developers**: Please use Sprig's [function documentation](http://masterminds.github.io/sprig/) for\ndetailed instructions and code snippets for the \u003e100 template functions available.\n\n**Go developers**: If you'd like to include Sprig as a library in your program,\nour API documentation is available [at GoDoc.org](http://godoc.org/github.com/Masterminds/sprig).\n\nFor standard usage, read on.\n\n### Load the Sprig library\n\nTo load the Sprig `FuncMap`:\n\n```go\n\nimport (\n  \"github.com/Masterminds/sprig/v3\"\n  \"html/template\"\n)\n\n// This example illustrates that the FuncMap *must* be set before the\n// templates themselves are loaded.\ntpl := template.Must(\n  template.New(\"base\").Funcs(sprig.FuncMap()).ParseGlob(\"*.html\")\n)\n\n\n```\n\n### Calling the functions inside of templates\n\nBy convention, all functions are lowercase. This seems to follow the Go\nidiom for template functions (as opposed to template methods, which are\nTitleCase). For example, this:\n\n```\n{{ \"hello!\" | upper | repeat 5 }}\n```\n\nproduces this:\n\n```\nHELLO!HELLO!HELLO!HELLO!HELLO!\n```\n\n## Principles Driving Our Function Selection\n\nWe followed these principles to decide which functions to add and how to implement them:\n\n- Use template functions to build layout. The following\n  types of operations are within the domain of template functions:\n  - Formatting\n  - Layout\n  - Simple type conversions\n  - Utilities that assist in handling common formatting and layout needs (e.g. arithmetic)\n- Template functions should not return errors unless there is no way to print\n  a sensible value. For example, converting a string to an integer should not\n  produce an error if conversion fails. Instead, it should display a default\n  value.\n- Simple math is necessary for grid layouts, pagers, and so on. Complex math\n  (anything other than arithmetic) should be done outside of templates.\n- Template functions only deal with the data passed into them. They never retrieve\n  data from a source.\n- Finally, do not override core Go template functions.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasterminds%2Fsprig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasterminds%2Fsprig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasterminds%2Fsprig/lists"}