{"id":16728351,"url":"https://github.com/tmc/tmpl","last_synced_at":"2025-04-10T11:07:20.712Z","repository":{"id":36811752,"uuid":"41118623","full_name":"tmc/tmpl","owner":"tmc","description":"tmpl - unix-friendly templating tool.","archived":false,"fork":false,"pushed_at":"2022-06-30T01:30:25.000Z","size":41,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T09:52:47.318Z","etag":null,"topics":["helm","unix"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmc.png","metadata":{"files":{"readme":"README.in","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2015-08-20T20:58:39.000Z","updated_at":"2024-12-11T10:26:59.000Z","dependencies_parsed_at":"2022-09-13T01:00:33.682Z","dependency_job_id":null,"html_url":"https://github.com/tmc/tmpl","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Ftmpl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Ftmpl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Ftmpl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Ftmpl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmc","download_url":"https://codeload.github.com/tmc/tmpl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208052,"owners_count":21065199,"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":["helm","unix"],"created_at":"2024-10-12T23:09:59.679Z","updated_at":"2025-04-10T11:07:20.680Z","avatar_url":"https://github.com/tmc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tmpl\n\nCommand tmpl renders a template with the current env vars as input.\n\ntmpl packs a punch in under 200 lines of code: a single static binary supplies the capabilities of\nmany more complicated templating engines.\n\nIt's especially helpful as an early entrypoint into containers to prepare configuration files.\n\n```sh\n$ tmpl -h\n{{.HELP}}\n```\n\nIt effectively exposes Go's [text/template](http://golang.org/pkg/text/template) for use in shells.\n\nReference [text/template](http://golang.org/pkg/text/template) documentation for template language specification.\n\nIt includes all of the template helpers from [sprig](https://godoc.org/github.com/Masterminds/sprig).\n\n## Safe Dockerfile Inclusion\n\nTo safely include in your build pipelines:\n```Dockerfile\nFROM ubuntu:bionic\n\nRUN apt-get update\nRUN apt-get install -y curl\n\nARG TMPL_URL=https://github.com/tmc/tmpl/releases/download/{{ .LATEST_TAG }}/tmpl_linux_amd64\nARG TMPL_SHA256SUM={{ .LINUX_SHASUM }}\nRUN curl -fsSLo tmpl ${TMPL_URL} \\\n\t\t\u0026\u0026 echo \"${TMPL_SHA256SUM}  tmpl\" | sha256sum -c - \\\n\t\t\u0026\u0026 chmod +x tmpl \u0026\u0026 mv tmpl /usr/local/bin/tmpl\n```\n\n## Safe Shell Scripting Inclusion\n\nTo safely include in your shell scripts:\n```bash\n#!/bin/bash\nset -euo pipefail\n\n# Helper Functions\ncase \"${OSTYPE}\" in\nlinux*) platform=linux\n\t;;\ndarwin*)\n\tplatform=darwin\n\t;;\n*) platform=unknown ;;\nesac\n\nfunction install_tmpl() {\n  if [[ \"${platform}\" == \"darwin\" ]]; then\n    TMPL_SHA256SUM={{ .MACOS_SHASUM }}\n  else\n    TMPL_SHA256SUM={{ .LINUX_SHASUM }}\n  fi\n  TMPL_URL=https://github.com/tmc/tmpl/releases/download/{{ .LATEST_TAG }}/tmpl_${platform}_amd64\n  curl -fsSLo tmpl ${TMPL_URL} \\\n    \u0026\u0026 echo \"${TMPL_SHA256SUM}  tmpl\" | sha256sum -c - \\\n    \u0026\u0026 chmod +x tmpl\n  mv tmpl /usr/local/bin/tmpl || echo \"could not move tmpl into place\"\n}\n\ncommand -v tmpl \u003e /dev/null || install_tmpl\n```\n\n### Example 1\nGiven a file 'a' with contents:\n\n\n\t{{\"{{\"}} range $key, $value := . {{\"}}\"}}\n\t  KEY:{{\"{{\"}} $key {{\"}}\"}} VALUE:{{\"{{\"}} $value {{\"}}\"}}\n\t{{\"{{\"}} end {{\"}}\"}}\n\nInvoking\n\n\t$ cat a | env -i ANSWER=42 ITEM=Towel `which tmpl`\n\nProduces\n\n\n\tKEY:ANSWER VALUE:42\n\t\n\tKEY:ITEM VALUE:Towel\n\n### Example 2\nGiven a file 'b' with contents:\n\n\n\tVERSION={{\"{{\"}}.HEAD{{\"}}\"}}\n\nInvoking\n\n\n\t$ cat b | HEAD=\"$(git rev-parse HEAD)\" tmpl\n\nProduces\n\n\tVERSION=4dce1b0a03b59b5d63c876143e9a9a0605855748\n\n### Example 3\nGiven a directory via the `-r` flag, tmpl recurses, expanding each path and file and produces a tarball to the output destination.\n\n\nInvoking\n\n    $ mkdir testdata/recursive-out\n\t$ tmpl -r testdata/recursive-example | tar -C testdata/recursive-out --strip-components=2 -xvf -\n\t$ cat testdata/recursive-out/user-tmc\n\nProduces (for me, at time of writing)\n\n\tFor the current user tmc:\n\tShell: /bin/bash\n\tEDITOR: vim\n\t😎\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmc%2Ftmpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmc%2Ftmpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmc%2Ftmpl/lists"}