{"id":15422616,"url":"https://github.com/heaths/go-template","last_synced_at":"2026-01-07T10:04:31.734Z","repository":{"id":63342052,"uuid":"567082276","full_name":"heaths/go-template","owner":"heaths","description":"Process project templates into new projects","archived":false,"fork":false,"pushed_at":"2024-02-29T06:04:34.000Z","size":76,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T04:33:09.476Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heaths.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-11-17T02:55:39.000Z","updated_at":"2022-11-17T07:02:41.000Z","dependencies_parsed_at":"2024-02-19T09:34:25.873Z","dependency_job_id":"c75a87b5-976f-405d-942c-3163c65f956a","html_url":"https://github.com/heaths/go-template","commit_stats":{"total_commits":24,"total_committers":1,"mean_commits":24.0,"dds":0.0,"last_synced_commit":"d123a5ae9b6dba19a2c027a67523b0f52faa710b"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":"heaths/template-golang","purl":"pkg:github/heaths/go-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Fgo-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Fgo-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Fgo-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Fgo-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heaths","download_url":"https://codeload.github.com/heaths/go-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Fgo-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28234564,"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":"2026-01-07T02:00:05.975Z","response_time":58,"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-01T17:39:02.196Z","updated_at":"2026-01-07T10:04:31.713Z","avatar_url":"https://github.com/heaths.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apply Templates\n\nProcess all template files recursively in a directory. This is useful for\nproject templates, for example, after creating a new repository from a template\nrepository.\n\n## Example\n\nAll files in the specified directory will be processed as templates. For now,\nthis project assumes all files are UTF-8 encoded. A _.git_ directory or file\n(worktree) will be skipped.\n\nFor every `{{param}}` found in a template, the user will be prompted to answer\nunless the named parameter was already in the parameter cache you pass. This\ncache can be pre-populated as well.\n\n```golang\nimport (\n    \"log\"\n\n    \"github.com/heaths/go-template\"\n)\n\nfunc Example() {\n    params := make(map[string]string)\n    err := template.Apply(\"testdata\", params,\n        template.WithLogger(log.Default(), true),\n    )\n    if err != nil {\n        log.Fatal(err)\n    }\n}\n```\n\n## Templates\n\nTemplates are processed using [`text/template`](https://pkg.go.dev/text/template).\nTemplate files contain a mix of text and actions surrounded by `{{` and `}}` e.g.,\n\n```markdown\n# {{param \"name\" \"\" \"What is the project name?\" | titlecase}}\n\nThis is an example.\n```\n\n### Functions\n\nIn addition to [built-in](https://pkg.go.dev/text/template#hdr-Functions) functions,\nthe following functions are also available:\n\n* `param \u003cname\u003e [\u003cdefault\u003e [\u003cprompt\u003e]]`\\\n  Replace with a parameter named `\u003cname\u003e`, or prompt using an optional `\u003cdefault\u003e`\n  with an optional `\u003cprompt\u003e`. If a `\u003cprompt\u003e` is not specified, the required\n  `\u003cname\u003e` is used. The type of `\u003cdefault\u003e` dictates valid input. Only `string`\n  and `int` are supported at this time.\n* `pluralize \u003ccount\u003e \u003cthing\u003e`\\\n  Append an \"s\" to `\u003cthing\u003e` if `\u003ccount\u003e` is not equal to 1. `\u003ccount\u003e` can be\n  either an `int` or a `string` representing an `int` e.g., \"1\".\n* `lowercase \u003cstring\u003e`\\\n  Change the case of `\u003cstring\u003e` to all lowercase characters.\n* `titlecase \u003cstring\u003e`\\\n  Change the case of `\u003cstring\u003e` to Title Case characters.\n* `uppercase \u003cstring\u003e`\\\n  Change the case of `\u003cstring\u003e` to UPPERCASE characters.\n* `replace \u003cfrom\u003e \u003cto\u003e \u003csource\u003e`\\\n  Replaces all occurrences of `\u003cfrom\u003e` to `\u003cto\u003e` in the `\u003csource\u003e` string.\n* `date`\\\n  Returns the current UTC date-time.\n* `date.Format \u003clayout\u003e`\\\n  Formats the date-time according to [`time.Format`](https://pkg.go.dev/time#Time.Format).\n* `date.Local`\\\n  Returns the current local date-time. You can call other `date` functions\n  on the returned value e.g., `date.Local.Year`.\n* `date.Year`\\\n  Returns the current UTC year.\n* `true`\\\n  Returns `true`. Useful as a default value to accept yes/Y or no/N answers.\n* `false`\\\n  Returns `false`. Useful as a default value to accept yes/Y or no/N answers.\n* `deleteFile`\\\n  Deletes the current file, or a list of file names relative to the repo root.\n\nNote that `date` functions including `Format`, `Local`, and `Year` are function calls\nand need to be closed in parenthesis if you want to pipe to another function like `printf`:\n\n```text\n{{param \"copyright\" ((date.Year) | printf \"Copyright %d\") \"What is the copyright year?\"}}\n```\n\nTo require an integer when prompting for the `copyright` parameter,\na better example is to pass the `int` that `date.Year` returns:\n\n```text\nCopyright {{param \"copyright\" (date.Year) \"What is the copyright year?\"}}\n```\n\n## License\n\nLicensed under the [MIT](LICENSE.txt) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheaths%2Fgo-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheaths%2Fgo-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheaths%2Fgo-template/lists"}