{"id":3492967,"name":"github.com/alecthomas/template","ecosystem":"go","description":"Package template implements data-driven templates for generating textual output.\n\nTo generate HTML output, see package html/template, which has the same interface\nas this package but automatically secures HTML output against certain attacks.\n\nTemplates are executed by applying them to a data structure. Annotations in the\ntemplate refer to elements of the data structure (typically a field of a struct\nor a key in a map) to control execution and derive values to be displayed.\nExecution of the template walks the structure and sets the cursor, represented\nby a period '.' and called \"dot\", to the value at the current location in the\nstructure as execution proceeds.\n\nThe input text for a template is UTF-8-encoded text in any format.\n\"Actions\"--data evaluations or control structures--are delimited by\n\"{{\" and \"}}\"; all text outside actions is copied to the output unchanged.\nActions may not span newlines, although comments can.\n\nOnce parsed, a template may be executed safely in parallel.\n\nHere is a trivial example that prints \"17 items are made of wool\".\n\nMore intricate examples appear below.\n\nHere is the list of actions. \"Arguments\" and \"pipelines\" are evaluations of\ndata, defined in detail below.\n\nAn argument is a simple value, denoted by one of the following.\n\nArguments may evaluate to any type; if they are pointers the implementation\nautomatically indirects to the base type when required.\nIf an evaluation yields a function value, such as a function-valued\nfield of a struct, the function is not invoked automatically, but it\ncan be used as a truth value for an if action and the like. To invoke\nit, use the call function, defined below.\n\nA pipeline is a possibly chained sequence of \"commands\". A command is a simple\nvalue (argument) or a function or method call, possibly with multiple arguments:\n\nA pipeline may be \"chained\" by separating a sequence of commands with pipeline\ncharacters '|'. In a chained pipeline, the result of the each command is\npassed as the last argument of the following command. The output of the final\ncommand in the pipeline is the value of the pipeline.\n\nThe output of a command will be either one value or two values, the second of\nwhich has type error. If that second value is present and evaluates to\nnon-nil, execution terminates and the error is returned to the caller of\nExecute.\n\nA pipeline inside an action may initialize a variable to capture the result.\nThe initialization has syntax\n\nwhere $variable is the name of the variable. An action that declares a\nvariable produces no output.\n\nIf a \"range\" action initializes a variable, the variable is set to the\nsuccessive elements of the iteration.  Also, a \"range\" may declare two\nvariables, separated by a comma:\n\nin which case $index and $element are set to the successive values of the\narray/slice index or map key and element, respectively.  Note that if there is\nonly one variable, it is assigned the element; this is opposite to the\nconvention in Go range clauses.\n\nA variable's scope extends to the \"end\" action of the control structure (\"if\",\n\"with\", or \"range\") in which it is declared, or to the end of the template if\nthere is no such control structure.  A template invocation does not inherit\nvariables from the point of its invocation.\n\nWhen execution begins, $ is set to the data argument passed to Execute, that is,\nto the starting value of dot.\n\nHere are some example one-line templates demonstrating pipelines and variables.\nAll produce the quoted word \"output\":\n\nDuring execution functions are found in two function maps: first in the\ntemplate, then in the global function map. By default, no functions are defined\nin the template but the Funcs method can be used to add them.\n\nPredefined global functions are named as follows.\n\nThe boolean functions take any zero value to be false and a non-zero\nvalue to be true.\n\nThere is also a set of binary comparison operators defined as\nfunctions:\n\nFor simpler multi-way equality tests, eq (only) accepts two or more\narguments and compares the second and subsequent to the first,\nreturning in effect\n\n(Unlike with || in Go, however, eq is a function call and all the\narguments will be evaluated.)\n\nThe comparison functions work on basic types only (or named basic\ntypes, such as \"type Celsius float32\"). They implement the Go rules\nfor comparison of values, except that size and exact type are\nignored, so any integer value, signed or unsigned, may be compared\nwith any other integer value. (The arithmetic value is compared,\nnot the bit pattern, so all negative integers are less than all\nunsigned integers.) However, as usual, one may not compare an int\nwith a float32 and so on.\n\nEach template is named by a string specified when it is created. Also, each\ntemplate is associated with zero or more other templates that it may invoke by\nname; such associations are transitive and form a name space of templates.\n\nA template may use a template invocation to instantiate another associated\ntemplate; see the explanation of the \"template\" action above. The name must be\nthat of a template associated with the template that contains the invocation.\n\nWhen parsing a template, another template may be defined and associated with the\ntemplate being parsed. Template definitions must appear at the top level of the\ntemplate, much like global variables in a Go program.\n\nThe syntax of such definitions is to surround each template declaration with a\n\"define\" and \"end\" action.\n\nThe define action names the template being created by providing a string\nconstant. Here is a simple example:\n\nThis defines two templates, T1 and T2, and a third T3 that invokes the other two\nwhen it is executed. Finally it invokes T3. If executed this template will\nproduce the text\n\nBy construction, a template may reside in only one association. If it's\nnecessary to have a template addressable from multiple associations, the\ntemplate definition must be parsed multiple times to create distinct *Template\nvalues, or must be copied with the Clone or AddParseTree method.\n\nParse may be called multiple times to assemble the various associated templates;\nsee the ParseFiles and ParseGlob functions and methods for simple ways to parse\nrelated templates stored in files.\n\nA template may be executed directly or through ExecuteTemplate, which executes\nan associated template identified by name. To invoke our example above, we\nmight write,\n\nor to invoke a particular template explicitly by name,","homepage":"https://github.com/alecthomas/template","licenses":"BSD-3-Clause","normalized_licenses":["BSD-3-Clause"],"repository_url":"https://github.com/alecthomas/template","keywords_array":[],"namespace":"github.com/alecthomas","versions_count":2,"first_release_published_at":"2016-04-05T07:15:01.000Z","latest_release_published_at":"2019-07-18T01:26:54.000Z","latest_release_number":"v0.0.0-20190718012654-fb15b899a751","last_synced_at":"2026-05-20T05:32:09.822Z","created_at":"2022-04-10T19:13:35.830Z","updated_at":"2026-05-20T05:32:09.822Z","registry_url":"https://pkg.go.dev/github.com/alecthomas/template","install_command":"go get github.com/alecthomas/template","documentation_url":"https://pkg.go.dev/github.com/alecthomas/template#section-documentation","metadata":{},"repo_metadata":{"id":27522550,"uuid":"31003500","full_name":"alecthomas/template","owner":"alecthomas","description":"Fork of Go's text/template adding newline elision","archived":false,"fork":false,"pushed_at":"2023-12-02T07:09:29.000Z","size":82,"stargazers_count":56,"open_issues_count":1,"forks_count":27,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-10-09T16:15:40.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/alecthomas.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-02-19T06:03:38.000Z","updated_at":"2024-04-23T15:45:56.000Z","dependencies_parsed_at":"2024-06-18T13:38:10.983Z","dependency_job_id":"fef06c21-126f-43d6-b0a3-5401a2ecc074","html_url":"https://github.com/alecthomas/template","commit_stats":{"total_commits":9,"total_committers":3,"mean_commits":3.0,"dds":0.2222222222222222,"last_synced_commit":"fb15b899a75114aa79cc930e33c46b577cc664b1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alecthomas/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Ftemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Ftemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Ftemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Ftemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alecthomas","download_url":"https://codeload.github.com/alecthomas/template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Ftemplate/sbom","scorecard":{"id":178783,"data":{"date":"2025-08-11","repo":{"name":"github.com/alecthomas/template","commit":"fb15b899a75114aa79cc930e33c46b577cc664b1"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":2,"reason":"Found 2/10 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T18:23:35.280Z","repository_id":27522550,"created_at":"2025-08-16T18:23:35.280Z","updated_at":"2025-08-16T18:23:35.280Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006610,"owners_count":26084148,"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-11T02:00:06.511Z","response_time":55,"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"},"owner_record":{"login":"alecthomas","name":"Alec Thomas","uuid":"41767","kind":"user","description":null,"email":"","website":"http://swapoff.org","location":"Sydney, Australia","twitter":null,"company":null,"icon_url":"https://avatars.githubusercontent.com/u/41767?v=4","repositories_count":166,"last_synced_at":"2025-09-21T13:52:00.439Z","metadata":{"has_sponsors_listing":true},"html_url":"https://github.com/alecthomas","funding_links":["https://github.com/sponsors/alecthomas"],"total_stars":28226,"followers":1387,"following":5,"created_at":"2022-11-02T17:36:56.193Z","updated_at":"2025-09-21T13:52:00.440Z","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alecthomas","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alecthomas/repositories"},"tags":[]},"repo_metadata_updated_at":"2025-10-11T08:36:15.457Z","dependent_packages_count":5792,"downloads":null,"downloads_period":null,"dependent_repos_count":104236,"rankings":{"downloads":null,"dependent_repos_count":0.009205062784531492,"dependent_packages_count":0.03872129671319226,"stargazers_count":6.04705611614446,"forks_count":4.5896472542260955,"docker_downloads_count":0.027114913202261243,"average":2.142348928614108},"purl":"pkg:golang/github.com/alecthomas/template","advisories":[],"docker_usage_url":"https://docker.ecosyste.ms/usage/go/github.com/alecthomas/template","docker_dependents_count":1943,"docker_downloads_count":11537637906,"usage_url":"https://repos.ecosyste.ms/usage/go/github.com/alecthomas/template","dependent_repositories_url":"https://repos.ecosyste.ms/api/v1/usage/go/github.com/alecthomas/template/dependencies","status":null,"funding_links":["https://github.com/sponsors/alecthomas"],"critical":true,"issue_metadata":{"last_synced_at":"2025-08-31T00:23:44.149Z","issues_count":5,"pull_requests_count":3,"avg_time_to_close_issue":29677.0,"avg_time_to_close_pull_request":17752.333333333332,"issues_closed_count":4,"pull_requests_closed_count":3,"pull_request_authors_count":3,"issue_authors_count":4,"avg_comments_per_issue":2.8,"avg_comments_per_pull_request":0.3333333333333333,"merged_pull_requests_count":2,"bot_issues_count":0,"bot_pull_requests_count":1,"past_year_issues_count":0,"past_year_pull_requests_count":0,"past_year_avg_time_to_close_issue":null,"past_year_avg_time_to_close_pull_request":null,"past_year_issues_closed_count":0,"past_year_pull_requests_closed_count":0,"past_year_pull_request_authors_count":0,"past_year_issue_authors_count":0,"past_year_avg_comments_per_issue":null,"past_year_avg_comments_per_pull_request":null,"past_year_bot_issues_count":0,"past_year_bot_pull_requests_count":0,"past_year_merged_pull_requests_count":0,"issues_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Ftemplate/issues","maintainers":[],"active_maintainers":[]},"versions_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Falecthomas%2Ftemplate/versions","version_numbers_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Falecthomas%2Ftemplate/version_numbers","latest_version_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Falecthomas%2Ftemplate/latest_version","dependent_packages_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Falecthomas%2Ftemplate/dependent_packages","related_packages_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Falecthomas%2Ftemplate/related_packages","codemeta_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Falecthomas%2Ftemplate/codemeta","maintainers":[]}