{"id":13816785,"url":"https://github.com/mscdex/zup","last_synced_at":"2025-07-22T10:37:33.265Z","repository":{"id":57406793,"uuid":"78491981","full_name":"mscdex/zup","owner":"mscdex","description":"A simple, fast template engine for node.js","archived":false,"fork":false,"pushed_at":"2024-03-12T17:41:04.000Z","size":16,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-06T00:03:11.607Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mscdex.png","metadata":{"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":"2017-01-10T03:00:15.000Z","updated_at":"2025-06-18T14:20:46.000Z","dependencies_parsed_at":"2024-06-19T10:09:21.895Z","dependency_job_id":null,"html_url":"https://github.com/mscdex/zup","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"49c8d8a8e69749ab60b08bfc0f74a1fddb0369e2"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mscdex/zup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fzup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fzup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fzup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fzup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mscdex","download_url":"https://codeload.github.com/mscdex/zup/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fzup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266477152,"owners_count":23935390,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-04T06:00:21.229Z","updated_at":"2025-07-22T10:37:33.243Z","avatar_url":"https://github.com/mscdex.png","language":"JavaScript","readme":"\nDescription\n===========\n\nA simple, fast template engine for node. The syntax is very close to that of other template engines, especially `ejs`.\n\nOne special feature of `zup` is that it ignores any 'end markers' that may appear in string literals inside a code block or expression. This is something that some other template engines (that usually use regexps for parsing) do not take into account and could lead to surprising results. For example:\n\n```\n\u003ch1\u003e[[- \"Look ma, a fake ]]!\" ]]\u003c/h1\u003e\n```\n\nIn this particular case, `zup` will correctly render this template like:\n\n```html\n\u003ch1\u003eLook ma, a fake ]]!\u003c/h1\u003e\n```\n\nBenchmark results can be found [here](https://github.com/mscdex/zup/wiki/Benchmarks).\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v4.0.0 or newer, although v6.0.0+ is recommended for best performance.\n\n\nInstall\n============\n\n    npm install zup\n\n\nExample\n=======\n\n```js\nvar compile = require('zup');\n\nvar fn = compile(`\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eMy First Article\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003e[[=z.heading.length \u003e 16 ? z.heading.slice(0,16) + '...' : z.heading]]\u003c/h1\u003e\n    [[ if (z.alert) { ]]\n      \u003ch3\u003e[[=z.alert]]\u003c/h3\u003e\n    [[ } ]]\n    \u003cpre\u003e[[-z.content\u003e\u003e]]\u003c/pre\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n`);\n\nconsole.log(fn({\n  heading: 'This title will be truncated',\n  content: `\n    My life story, and I'm not kidding this time...\n  `,\n  alert: '\u003cb\u003eHI MOM!\u003c/b\u003e'\n}));\n\n// Displays:\n//\n// \u003chtml\u003e\n//   \u003chead\u003e\n//     \u003ctitle\u003eMy First Article\u003c/title\u003e\n//   \u003c/head\u003e\n//   \u003cbody\u003e\n//     \u003ch1\u003eThis title will ...\u003c/h1\u003e\n//     \n//       \u003ch3\u003e\u0026lt;b\u0026gt;HI MOM!\u0026lt;/b\u0026gt;\u003c/h3\u003e\n//     \n//     \u003cpre\u003eMy life story, and I'm not kidding this time...\u003c/pre\u003e\n//   \u003c/body\u003e\n// \u003c/html\u003e\n//\n```\n\nSyntax\n======\n\n`zup` expressions/code blocks are enclosed by (customizable) start and end markers.\n\nSpecial symbols placed right inside the start and end markers control the output of expressions.\n\nSymbols that can be used after **start** markers:\n\n  * `=` - This indicates that the output resulting from the expression should have some special characters converted to their respective html entity names:\n\n    * `\u003c`, `\u003e`, `\u0026`, `'`, `\"`\n\n  * `-` - (opposite of `=`) This indicates that the output resulting from the expression should *not* have special characters converted to their respective html entity names.\n\n  * *(none)* - This indicates a generic code block, useful for control flow (e.g. `if`, `while`, `for`, etc.) and other such statements.\n\nSymbols that can be used before **end** markers:\n\n  * `\u003e` - If just a single `\u003e`, this indicates that only newlines (`'\\r'` and `'\\n'`) will be trimmed from the beginning and end of the output returned from the expression.\n\n  * `\u003e\u003e` - This indicates that all whitespace (`'\\r'`, `'\\n'`, `'\\t'`, `' '`, and `'\\f'`) will be trimmed from the beginning and end of the output returned from the expression.\n\nThere is also an `include()` helper available inside templates:\n\n  * **include**(\u003c _string_ \u003ename[, \u003c _object_ \u003edata]) - _(void)_ - Inserts the rendered output of the template specified by `name` at the current position in the current template. `data` is an optional value that you can pass to the template's render function to use as a data source. How the template identified by `name` is looked up is described below in the description of `cache.get()`.\n\nAPI\n===\n\n`require('zup')` returns the template compiler function.\n\n* **compile**(\u003c _string_ \u003etemplate[, \u003c _object_ \u003eoptions]) - _function_ - Creates and returns a compiled template as a renderer function. The following are valid `options` properties:\n\n    * **objName** - _string_ - This is the name of the object used to access data variables. **Default:** `'z'`\n\n    * **start** - _string_ - The start marker used to indicate the start of a zup expression or code block. **Default:** `'[['`\n\n    * **end** - _string_ - The end marker used to indicate the end of a zup expression or code block. **Default:** `']]'`\n\n    * **basePath** - _string_ - This is the default base path used for looking up templates referenced by calls to `include()` in a template. **Default:** (the directory of the \"main\" script)\n\n    * **cache** - _object_ - This object should contain `get()` and `set()` functions:\n\n      * **get**(\u003c _string_ \u003ename) - _(mixed)_ - `name` is the string passed to the `include()` function inside a template. Return a _function_ to use that for rendering the requested template. If no value/`undefined` is returned, then the template will be searched for on the local file system using the configured `basePath` and appending `'.ztpl'` to the end of `name`.\n\n      * **set**(\u003c _string_ \u003ename, \u003c _string_ \u003efilepath, \u003c _function_ \u003ecompiled) - _(void)_ - `name` is the string passed to the `include()` function inside a template, `filepath` is the absolute path of the newly compiled template, and `compiled` is the resulting renderer function. Store `compiled` somewhere for use in `get()` to avoid repeated template parsing/compilation.\n","funding_links":[],"categories":["Packages"],"sub_categories":["HTTP"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fzup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmscdex%2Fzup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fzup/lists"}