{"id":18254253,"url":"https://github.com/brikcss/tplit","last_synced_at":"2025-04-08T21:47:24.188Z","repository":{"id":143745473,"uuid":"156764057","full_name":"brikcss/tplit","owner":"brikcss","description":"A simple, small, fast, all-purpose templating engine using the power and flexibility of native JavaScript template literals.","archived":false,"fork":false,"pushed_at":"2019-01-17T00:04:45.000Z","size":257,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T10:34:48.790Z","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/brikcss.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-08T20:21:50.000Z","updated_at":"2018-11-13T22:52:46.000Z","dependencies_parsed_at":"2023-04-02T12:20:12.227Z","dependency_job_id":null,"html_url":"https://github.com/brikcss/tplit","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/brikcss%2Ftplit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brikcss%2Ftplit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brikcss%2Ftplit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brikcss%2Ftplit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brikcss","download_url":"https://codeload.github.com/brikcss/tplit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247934808,"owners_count":21020724,"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-11-05T10:11:16.022Z","updated_at":"2025-04-08T21:47:24.164Z","avatar_url":"https://github.com/brikcss.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tplit\n\nA simple, small, fast, all-purpose templating engine using the power and flexibility of native JavaScript template literals.\n\n\u003c!-- Shields. --\u003e\n\u003cp\u003e\n    \u003c!-- NPM version. --\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@brikcss/tplit\"\u003e\u003cimg alt=\"NPM version\" src=\"https://img.shields.io/npm/v/@brikcss/tplit.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003c!-- NPM downloads/month. --\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@brikcss/tplit\"\u003e\u003cimg alt=\"NPM downloads per month\" src=\"https://img.shields.io/npm/dm/@brikcss/tplit.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003c!-- Travis branch. --\u003e\n    \u003ca href=\"https://github.com/brikcss/tplit/tree/master\"\u003e\u003cimg alt=\"Travis branch\" src=\"https://img.shields.io/travis/rust-lang/rust/master.svg?style=flat-square\u0026label=master\"\u003e\u003c/a\u003e\n    \u003c!-- Codacy. --\u003e\n    \u003ca href=\"https://www.codacy.com/app/thezimmee/tplit\"\u003e\u003cimg alt=\"NPM version\" src=\"https://img.shields.io/codacy/grade/ac90d04f29fb42b0840ef2a5d199bcfa/master.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003c!-- Coveralls --\u003e\n    \u003ca href='https://coveralls.io/github/brikcss/tplit?branch=master'\u003e\u003cimg src='https://img.shields.io/coveralls/github/brikcss/tplit/master.svg?style=flat-square' alt='Coverage Status' /\u003e\u003c/a\u003e\n    \u003c!-- JS Standard style. --\u003e\n    \u003ca href=\"https://standardjs.com\"\u003e\u003cimg alt=\"JavaScript Style Guide\" src=\"https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003c!-- Prettier code style. --\u003e\n    \u003ca href=\"https://prettier.io/\"\u003e\u003cimg alt=\"code style: prettier\" src=\"https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003c!-- Semantic release. --\u003e\n    \u003ca href=\"https://github.com/semantic-release/semantic-release\"\u003e\u003cimg alt=\"semantic release\" src=\"https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003c!-- Commitizen friendly. --\u003e\n    \u003ca href=\"http://commitizen.github.io/cz-cli/\"\u003e\u003cimg alt=\"Commitizen friendly\" src=\"https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003c!-- MIT License. --\u003e\n    \u003ca href=\"https://choosealicense.com/licenses/mit/\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/npm/l/express.svg?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## Environment and browser support\n\n| Node | ES Module | Browser | UMD | CLI |\n| :--: | :-------: | :-----: | :-: | :-: |\n|  ✓   |     ✓     |    x    |  ✓  |  x  |\n\n## Install\n\n```sh\nnpm i -D @brikcss/tplit\n```\n\n## Usage\n\nThere are two ways to use tplit, each has their pros and cons:\n\n1. Pass a string with `tplit()`:\n\n   _Pros_: Most flexible, most configuration options.\u003cbr\u003e\n   _Cons_: Can not use outside scope / context (though you can pass your own context data object).\n\n   _Syntax_:\n\n   ```js\n   tplit((template = \"\"), (options = {}))((context = {}));\n   ```\n\n   _Example_:\n\n   ```js\n   import tplit from \"@brikcss/tplit\";\n   const compiled = tplit(\"Hello ${this.name}\")({ name: \"World\" });\n   const compiledWithOptions = tplit(\"Hello ${this.name}\", {\n     prop: \"props\",\n     map: value =\u003e value.toUpperCase()\n   })({ name: \"World\" });\n   // console.log(compiled) =\u003e 'Hello World'\n   // console.log(compiledWithOptions) =\u003e 'Hello WORLD'\n   ```\n\n2. Call with template literal function with `tplitReduce()`:\n\n   _Pros_: Can use outside scope / context.\u003cbr\u003e\n   _Cons_: Fewer configuration options.\n\n   _Syntax_:\n\n   ```js\n   tplitReduce((map = arg =\u003e arg))`My template string`;\n   ```\n\n   _Example_:\n\n   ```js\n   import { tplitReduce } from \"@brikcss/tplit\";\n   const name = \"World\";\n   const compiled = tplitReduce(\n     (map = arg =\u003e arg.toUpperCase())\n   )`Hello ${name}`;\n   // console.log(compiled) =\u003e 'Hello WORLD'\n   ```\n\n## Options\n\n- `prop` {`String`} (`this`): Property to use for context Object. _Note: Not available with default `tplit()` method._\n- `split` {`Boolean`} (`false`): Set true to split the template and return an Array of `[chunks, ...values]`. This would allow you to pass to other functions and further manipulate the template as desired. _Note: Not available with default `tplit()` method._\n- `map` {`Function`} (`(value, key, context) =\u003e value`): Function to manipulate template values. This would allow you to, for example, sanitize HTML or otherwise manipulate context values.\n\n## Examples\n\nFor more examples, see the [tests](./src/tplit.test.js).\n\n\u003c!-- ## References\n\n- https://github.com/drulac/template-literal\n- https://github.com/tunnckoCore/gana-compile\n- https://github.com/tunnckoCore/es6-template\n- https://github.com/bredele/intertag\n- https://github.com/bredele/tag-reduce\n- https://github.com/steelbrain/tagged-template-literals --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrikcss%2Ftplit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrikcss%2Ftplit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrikcss%2Ftplit/lists"}