{"id":16231634,"url":"https://github.com/hustcc/tplv","last_synced_at":"2025-08-12T15:06:18.666Z","repository":{"id":43465853,"uuid":"228285910","full_name":"hustcc/tplv","owner":"hustcc","description":":footprints: Nano string template library for modern, based on ES6 template string syntax.","archived":false,"fork":false,"pushed_at":"2022-03-01T13:30:11.000Z","size":50,"stargazers_count":31,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-17T07:51:29.915Z","etag":null,"topics":["es6","string","strings","template","tplv"],"latest_commit_sha":null,"homepage":"https://github.com/hustcc/tplv","language":"TypeScript","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/hustcc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://paypal.me/hustcc","https://atool.vip"]}},"created_at":"2019-12-16T02:23:20.000Z","updated_at":"2024-09-29T08:24:45.000Z","dependencies_parsed_at":"2022-09-10T06:02:07.227Z","dependency_job_id":null,"html_url":"https://github.com/hustcc/tplv","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Ftplv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Ftplv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Ftplv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Ftplv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hustcc","download_url":"https://codeload.github.com/hustcc/tplv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244444445,"owners_count":20453726,"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":["es6","string","strings","template","tplv"],"created_at":"2024-10-10T13:06:22.645Z","updated_at":"2025-03-19T14:30:43.586Z","avatar_url":"https://github.com/hustcc.png","language":"TypeScript","readme":"# TPLV\n\n\u003e Nano(~170 bytes), High performance string template library, based on ES6 String template syntax.\n\n[![npm Version](https://img.shields.io/npm/v/tplv.svg)](https://www.npmjs.com/package/tplv)\n[![Build Status](https://github.com/hustcc/tplv/workflows/build/badge.svg)](https://github.com/hustcc/tplv/actions)\n[![Coverage Status](https://coveralls.io/repos/github/hustcc/tplv/badge.svg?branch=master)](https://coveralls.io/github/hustcc/tplv?branch=master)\n[![npm License](https://img.shields.io/npm/l/tplv.svg)](https://www.npmjs.com/package/tplv)\n\n\n## Install\n\n```bash\n$ npm i --save tplv\n```\n\n\n## Usage\n\n - `render` template string\n\n```ts\nimport { render } from 'tplv';\n\nconst template = '${ name }, ${value}(${percent} | Top ${array[2]})';\n\nconst data = {\n  name: 'Hangzhou',\n  value: 1200,\n  percent: '13%',\n  array: [1, 2, 3, 4]\n};\n\nrender(template, data); // `Hangzhou, 1200(13% | Top 3)` will be got\n```\n\n - `compile` mode\n\n\u003e For `13x` faster performance then render mode.\n\n```ts\nimport { compile } from 'tplv';\n\nconst template = '${ name }, ${value}(${percent} | Top ${array[2]})';\n\nconst data = {\n  name: 'Hangzhou',\n  value: 1200,\n  percent: '13%',\n  array: [1, 2, 3, 4]\n};\n\nconst fn = compile(template, ['name', 'value', 'percent', 'array']);\n\nfn(data); // `Hangzhou, 1200(13% | Top 3)` will be got\n```\n\n\n## Perf\n\nRun performance test with [rendering-test](https://aui.github.io/art-template/rendering-test/).\n\n![perf test](https://user-images.githubusercontent.com/7856674/74140231-abef9300-4c2f-11ea-875d-d57e845e9ef7.png)\n\n\n## Principle\n\nThe core code and principles are as follows:\n\n```ts\nfunction render(template, data) {\n  const ks = Object.keys(data);\n  const vs = ks.map((k) =\u003e data[k]);\n\n  const t = `return \\`${template}\\``;\n  const f = new Function(...ks, t);\n\n  return f(...vs);\n}\n```\n\n\n## Dev\n\n```bash\n# install dependence\n$ npm install\n\n# run test cases\n$ npm run test\n\n# run performance for render / compile mode\n$ npm run perf\n\n# build package\n$ npm run build\n```\n\n\n## License\n\nMIT@[hustcc](https://github.com/hustcc).\n","funding_links":["https://paypal.me/hustcc","https://atool.vip"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhustcc%2Ftplv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhustcc%2Ftplv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhustcc%2Ftplv/lists"}