{"id":15478382,"url":"https://github.com/willtpwise/parsetemplate","last_synced_at":"2026-01-07T21:07:08.095Z","repository":{"id":40755675,"uuid":"280293484","full_name":"willtpwise/parseTemplate","owner":"willtpwise","description":"A simple library for parsing JS template strings","archived":false,"fork":false,"pushed_at":"2023-01-06T11:41:35.000Z","size":748,"stargazers_count":0,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-23T20:42:58.543Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/willtpwise.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":"2020-07-17T01:06:59.000Z","updated_at":"2020-07-27T23:04:42.000Z","dependencies_parsed_at":"2023-02-06T00:15:26.381Z","dependency_job_id":null,"html_url":"https://github.com/willtpwise/parseTemplate","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willtpwise%2FparseTemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willtpwise%2FparseTemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willtpwise%2FparseTemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willtpwise%2FparseTemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willtpwise","download_url":"https://codeload.github.com/willtpwise/parseTemplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246042013,"owners_count":20714147,"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-02T04:03:52.121Z","updated_at":"2026-01-07T21:07:08.001Z","avatar_url":"https://github.com/willtpwise.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parse Template\n\n\u003e A very light weight library which allows you to process tokenised strings\n\nSay you have a string like this:\n```javascript\nconst input = 'Hello ${firstName}'\n```\n\nYou can parse it like this:\n```javascript\nimport { parseTemplate } from 'parse-template'\n\nconst meta = { firstName: 'Jess' }\n\nparseTemplate(input, meta) // 'Hello Jess'\n```\n\n### Installing\n```\nnpm i --save parse-template\n```\n\n## Features\n\n### Object syntax\n```javascript\nconst meta = { user: { firstName: 'Joe' } }\n\nparseTemplate('Hello ${user.firstName}', meta) // 'Hello Joe'\n```\n\n### Array syntax\n```javascript\nconst meta = { guests: [{ firstName: 'Alex'}] }\n\nparseTemplate('Hello ${guests[0].firstName}', meta) // 'Hello Alex'\n```\n\n### Fallback syntax\n```javascript\nconst meta = { nickName: null, firstName: 'Sam' }\n\nparseTemplate('Hello ${nickname || firstName || \"there\"}', meta) // 'Hello Sam'\n```\n\n### Empty value\nEmpty values are replaced with an empty string\n```javascript\nconst meta = { nickName: null }\n\nparseTemplate('Hello ${nickname}', meta) // 'Hello '\n```\n\n### Undefined value\nUndefined values are replaced with an empty string\n```javascript\nconst meta = {}\n\nparseTemplate('Hello ${nickname}', meta) // 'Hello '\n```\n\n### Object unwrapping\nThe resolved \"meta\" value must be either a string or a number, otherwise it is ignored. So objects and other non string/number values are ommitted\n```javascript\nconst meta = { user: { nickName: 'Roger' } }\n\nparseTemplate('Hello ${user}', meta) // 'Hello '\n```\n\n## Contributing\n\nThanks for the help :) Please fork this repo then submit a PR back into.\n\n### Local Development\n```\nnpm i\n\nnpm test\n\nnpm run build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilltpwise%2Fparsetemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilltpwise%2Fparsetemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilltpwise%2Fparsetemplate/lists"}