{"id":26164724,"url":"https://github.com/optum/templ","last_synced_at":"2026-05-01T22:33:29.266Z","repository":{"id":251935661,"uuid":"833652872","full_name":"Optum/templ","owner":"Optum","description":"Easy Handling of Delimiters that Accompany Optional Data","archived":false,"fork":false,"pushed_at":"2025-06-27T18:55:06.000Z","size":105,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-26T10:47:13.568Z","etag":null,"topics":["java","templates"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Optum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null,"notice":"NOTICE.txt","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-25T13:30:51.000Z","updated_at":"2025-06-27T18:52:51.000Z","dependencies_parsed_at":"2024-09-12T05:38:51.652Z","dependency_job_id":"16002c55-754c-49f2-b1b9-3b716cfb3e70","html_url":"https://github.com/Optum/templ","commit_stats":null,"previous_names":["optum/templ"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/Optum/templ","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Optum%2Ftempl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Optum%2Ftempl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Optum%2Ftempl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Optum%2Ftempl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Optum","download_url":"https://codeload.github.com/Optum/templ/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Optum%2Ftempl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32515838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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":["java","templates"],"created_at":"2025-03-11T15:39:59.125Z","updated_at":"2026-05-01T22:33:29.226Z","avatar_url":"https://github.com/Optum.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# templ\n\n## Easy Handling of Delimiters that Accompany Optional Data\n\nThis library provides a simple solution to a common use case in configuration variables:\n\u003e _A delimiter is needed to accompany optional data, but must not be present when the optional data is missing._\n\nTraditionally this scenario is solved in one of two ways:\n* Treat the delimiter as required, forcing a default value to always be defined and available.\n* Embed the optional delimiter in the actual value of the optional data, essentially _corrupting_ the value of the data (`PORT=\"80\"` becomes `PORT=\":80\"` but clearly the value `:80` is not a valid port number.)\n\n## templ - Is a Primitive Library\nDon't expect to use `templ` without writing a little code around it: it is primitive.  This library Does One Thing: the substitution processing.  You'll need to provide the bindings into your context and use case.\n\n## templ - Solution\nThe solution pattern provided by `templ` is to include the delimiter(s) inside the double-braces template substitution syntax `{{}}` (as a prefix and/or a suffix).\n\n### Case 1: Undefined value - delimiter is omitted\n```\nAPI_HOST=\"api.example.com\"\nAPI_ENDPOINT=\"{{API_HOST}}{{:API_PORT}}\"\n```\n#### Result: `api.example.com`\n(With `API_PORT` undefined, the `:` is excluded from the result.)\n\n### Case 2: Defined value - delimiter is included\n```\nAPI_HOST=\"api.example.com\"\nAPI_PORT=\"8080\"\nAPI_ENDPOINT=\"{{API_HOST}}{{:API_PORT}}\"\n```\n#### Result: `api.example.com:8080`\n(With `API_PORT` defined, the `:` is included in the result.)\n\n## Supported Delimiters\nThere are eighteen supported delimiters:\n\n1. ` \u003cspace\u003e `\n2. ` , `\n3. ` . `\n4. ` ; `\n5. ` : `\n6. ` ? `\n7. ` \u0026 `\n8. ` @ `\n9. ` # `\n10. ` / `\n11. ` ( `\n12. ` ) `\n13. ` \u003c `\n14. ` \u003e `\n15. ` _ `\n16. ` - `\n17. ` \\ `\n18. ` | `\n\n### Delimiter Rules\n* Delimiters can be used as a prefix and/or suffix.\n* Any number of delimiters can be used in any combination.\n\n## Nested Evaluation (Dynamic Variables)\nVariables can be dynamic.\n\n### Example 1:\n```\nINSTANCE=\"3\"\nHOST_1=\"devhost1.example.com\"\nHOST_2=\"devhost2.example.com\"\nHOST_3=\"qa.example.com\"\nHOST_4=\"example.com\"\nSERVICE_ENDPOINT=\"{{HOST_{{INSTANCE}}}}\"\n```\n\nThis usefulness is compounded when multiple variables are resolved:\n\n### Example 1:\n```\nINSTANCE=\"3\"\nHOST_1=\"devhost.example.com\"\nPORT_1=\"8080\"\nHOST_2=\"devhost.example.com\"\nPORT_2=\"8081\"\nHOST_3=\"qa.example.com\"\nHOST_4=\"example.com\"\nSERVICE_ENDPOINT=\"{{HOST_{{INSTANCE}}}}{{:PORT_{{INSTANCE}}}}\"\n```\n\n## UPPERCASE\nThe value returned by a template evaluation can be converted to uppercase using the `^` character before the variable name.\n\n### Example:\n```\nENV=\"dev\"\nHOST_DEV=\"vm123.example.com\"\nHOST_QA=\"qa.example.com\"\nHOST_PROD=\"example.com\"\nSERVICE_ENDPOINT=\"{{HOST_{{^ENV}}}}\"\n```\n\u003e This example shows both the `^` UPPERCASE syntax, and the nested-template resolution to resolve values dynamically.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptum%2Ftempl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foptum%2Ftempl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptum%2Ftempl/lists"}