{"id":21851841,"url":"https://github.com/nberlette/templette","last_synced_at":"2026-05-13T05:37:48.622Z","repository":{"id":57689620,"uuid":"492633690","full_name":"nberlette/templette","owner":"nberlette","description":"Petite template engine written in TypeScript","archived":false,"fork":false,"pushed_at":"2023-10-17T18:35:40.000Z","size":107,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-27T19:09:42.275Z","etag":null,"topics":["api","cjs","class","compiler","dts","esm","inject","mustache","placeholder","template","templette","typescript"],"latest_commit_sha":null,"homepage":"https://npm.runkit.com/templette","language":"JavaScript","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/nberlette.png","metadata":{"funding":{"ko_fi":"nberlette"},"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","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,"publiccode":null,"codemeta":null}},"created_at":"2022-05-16T00:07:55.000Z","updated_at":"2023-01-26T00:38:28.000Z","dependencies_parsed_at":"2024-11-14T13:47:22.057Z","dependency_job_id":null,"html_url":"https://github.com/nberlette/templette","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"bceb42bc68fd8878def56b13fb5a72f48c6f28cd"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nberlette%2Ftemplette","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nberlette%2Ftemplette/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nberlette%2Ftemplette/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nberlette%2Ftemplette/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nberlette","download_url":"https://codeload.github.com/nberlette/templette/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244846641,"owners_count":20520164,"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":["api","cjs","class","compiler","dts","esm","inject","mustache","placeholder","template","templette","typescript"],"created_at":"2024-11-28T01:11:37.829Z","updated_at":"2026-05-13T05:37:48.595Z","avatar_url":"https://github.com/nberlette.png","language":"JavaScript","funding_links":["https://ko-fi.com/nberlette"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=center\u003e\n\u003ch1\u003e\u003ccode\u003etemplette\u003c/code\u003e\u003c/h1\u003e\n\u003ch4\u003epetite template compilation class\u003c/h4\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\n## Getting Started\n\n\u003cbr\u003e\n\n### 1. Install\n\n```bash\npnpm add -D templette\n```\n\n```bash\nyarn add --dev templette\n```\n\n```bash\nnpx i -D templette\n```\n\n### 2. Import\n\n```js\n// es modules\nimport Templette from 'templette';\n```\n\n```js\n// commonjs\nconst Templette = require('templette');\n```\n\n### 3. Instantiate\n\n```js\nconst t = new Templette();\n// or\nconst t = new Templette('Hello {{name}}!');\n```\n\n### 4. Compile\n\n```js\n// when you've defined the template in the constructor\nt.render({name: 'nberlette'});\n```\n\n```js\n// to define the template on the fly\nt.compile('Hello {{name}}!', {name: 'nberlette'});\n```\n\n### Or, use the static compile method\n\n```js\nTemplette.compile('Hello {{name}}!', {name: 'nberlette'});\n```\n\n---\n\n## API\n\n\u003cbr\u003e\n\n\u003ca name=\"static-compile\"\u003e\u003c/a\u003e\n\n\u003ch3\u003e\u003ccode\u003estatic \u003cstrong\u003ecompile\u003c/strong\u003e(\u003cstrong\u003etemplate\u003c/strong\u003e: \u003cem\u003e\u003cu\u003eTemplate\u003c/u\u003e\u003c/em\u003e, \u003cstrong\u003evalues\u003c/strong\u003e: \u003cem\u003e\u003cu\u003eValues\u003c/u\u003e\u003c/em\u003e): string\u003c/code\u003e\u003c/h3\u003e\u003cbr\u003e\n\n**Templette's main compile method, powered by JavaScript's powerful builtin RegExp engine.**\n\n**Type**: `global function`\n\n**Params**\n\n- template \u003ccode\u003eTemplate\u003c/code\u003e - the raw template string we want to compile\n- values \u003ccode\u003eValues\u003c/code\u003e - substitutions to make, either as a generic list (for numbered keys), or as a map-style\n  object to replace named keys or deep (dot-notation) paths.\n\n**Returns**: \u003ccode\u003estring\u003c/code\u003e\n\n\u003cbr\u003e\n\n#### Example\n\n```js\nTemplette.compile('Hello {{name}}!', {name: 'Nick'});\n// Hello Nick!\n```\n\n\u003cbr\u003e\u003chr\u003e\u003cbr\u003e\n\n\u003ca name=\"cleanup\"\u003e\u003c/a\u003e\n\n\u003ch3\u003e\u003ccode\u003estatic \u003cstrong\u003ecleanup\u003c/strong\u003e(\u003cstrong\u003etemplate\u003c/strong\u003e: \u003cem\u003e\u003cu\u003eTemplate\u003c/u\u003e\u003c/em\u003e, \u003cstrong\u003esubstitutions\u003c/strong\u003e: \u003cem\u003e[\u003cu\u003estring\u003c/u\u003e | \u003cu\u003enumber\u003c/u\u003e | \u003cu\u003eRegExp\u003c/u\u003e,  \u003cu\u003eany\u003c/u\u003e]\u003c/em\u003e): string\u003c/code\u003e\u003c/h3\u003e\u003cbr\u003e\n\n**Cleanup a template string and remove some inconsistencies.**\n\n**Kind**: global function **Returns**: \u003ccode\u003estring\u003c/code\u003e - formatted and normalized template string **Params**\n\n- template \u003ccode\u003estring\u003c/code\u003e - raw unformatted template string\n- [substitutions] \u003ccode\u003eRecord.\u0026lt;string, unknown\u0026gt;\u003c/code\u003e - optional map of substitutions to make: each property\n  name is the search pattern or string, and its value is the replacement string or function.\n\n\u003cbr\u003e\u003chr\u003e\u003cbr\u003e\n\n\u003ca name=\"compile\"\u003e\u003c/a\u003e\n\n### `compile(template, values)`  ⇒  \u003ccode\u003estring\u003c/code\u003e\n\nTemplette's main compile method, powered by JavaScript's powerful builtin RegExp engine.\n\n**Type**: `global function`\n\n**Params**:\n\n- template \u003ccode\u003eTemplate\u003c/code\u003e - the raw template string we want to compile\n- values \u003ccode\u003eValues\u003c/code\u003e - substitutions to make, either as a generic list (for numbered keys), or as a map-style\n  object to replace named keys or deep (dot-notation) paths.\n\n#### **Example**:\n\n```js\nTemplette.compile('Hello {{name}}!', {name: 'Nick'});\n// Hello Nick!\n```\n\n\u003cbr\u003e\u003chr\u003e\u003cbr\u003e\n\n\u003ca name=\"render\"\u003e\u003c/a\u003e\n\n### `render(values)`  ⇒  \u003ccode\u003estring\u003c/code\u003e\n\nRender the template with provided values.\n\n**Type**: `global function`\n\n**Params**:\n\n- values \u003ccode\u003eValues\u003c/code\u003e - substitutions to make, either as a generic list (for numbered keys), or as a map-style\n  object to replace named keys or deep (dot-notation) paths.\n\n\u003cbr\u003e\u003chr\u003e\u003cbr\u003e\n\n\u003cdiv align=center\u003e\n\nMIT © [Nicholas Berlette](https://github.com/nberlette) · inspired by\n[@lukeed/templite](https://github.com/lukeed/templite)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnberlette%2Ftemplette","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnberlette%2Ftemplette","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnberlette%2Ftemplette/lists"}