{"id":17651324,"url":"https://github.com/nash403/interpolate-tmpl","last_synced_at":"2025-06-28T04:33:39.605Z","repository":{"id":57275280,"uuid":"68532639","full_name":"nash403/interpolate-tmpl","owner":"nash403","description":"Simple string interpolation.","archived":false,"fork":false,"pushed_at":"2016-09-20T17:24:24.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-05T16:19:13.972Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nash403.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-18T16:17:09.000Z","updated_at":"2019-02-26T17:39:25.000Z","dependencies_parsed_at":"2022-09-15T19:10:15.528Z","dependency_job_id":null,"html_url":"https://github.com/nash403/interpolate-tmpl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nash403%2Finterpolate-tmpl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nash403%2Finterpolate-tmpl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nash403%2Finterpolate-tmpl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nash403%2Finterpolate-tmpl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nash403","download_url":"https://codeload.github.com/nash403/interpolate-tmpl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nash403%2Finterpolate-tmpl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258778090,"owners_count":22756225,"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":[],"created_at":"2024-10-23T11:41:46.723Z","updated_at":"2025-06-28T04:33:39.584Z","avatar_url":"https://github.com/nash403.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# interpolate-tmpl\r\n#### Simple string interpolation.\r\n\r\nSimple interpolation utility based on the JavaScript `RegExp`, `String#replace` and the npm module [`get-safe`](https://www.npmjs.com/package/get-safe \"npm module get-safe\") for safe access to nested properties.\r\n***\r\n#### Install:\r\n`npm install interpolate-tmpl --save`\r\n\r\n#### How to use\r\n ```JavaScript\r\n\r\nlet interpolate = require('interpolate-tmpl');\r\n\r\nlet str = `\r\n\u003cdiv\u003e\r\n \u003ch1 class=\"{{ color}}\"\u003e{{ title('Albert',Einstein  ) }}\u003c/h1\u003e\r\n \u003cp\u003eBorn on {{birthDate(March, 14, '1879')}}\u003c/p\u003e\r\n \u003cp\u003eDied in {{'death.location' }}, {{ death.date }}\u003c/p\u003e\r\n\u003c/div\u003e`;\r\n\r\nlet data = {\r\n  color:\"red\",\r\n  death: {\r\n    location: \"Princeton\",\r\n    date: \"April 18, 1955\"\r\n  },\r\n  title(firstname, lastname) {\r\n  return `Mr. ${firstname} ${lastname}`;\r\n  },\r\n  birthDate(month, day, year) {\r\n    return `${month} ${day}, ${year}`;\r\n  }\r\n};\r\n\r\nconsole.log(interpolate(str, data, \"{{}}\") ); // Logs interpolated string\r\n```\r\n\r\nYou can call functions with simple arguments (strings \u0026 integers only, no variable) and change the delimiter. Just pass the delimiter as a string to the interpolate function as the last parameter (default is `{{}}`).\r\n\r\n**Supported delimiters are:** `{{}}`, `{}`, `[[]]`, `[]`, `\u003c$$\u003e`, `\u003c##\u003e`, `\u003c%%\u003e`.\r\n\r\n***\r\nThe browser version adds a `interpolate` function to the window object.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnash403%2Finterpolate-tmpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnash403%2Finterpolate-tmpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnash403%2Finterpolate-tmpl/lists"}