{"id":15209090,"url":"https://github.com/mourner/yeahjs","last_synced_at":"2026-01-18T22:02:40.354Z","repository":{"id":37637797,"uuid":"263931474","full_name":"mourner/yeahjs","owner":"mourner","description":"A tiny, modern, fast EJS templating library","archived":false,"fork":false,"pushed_at":"2025-02-17T15:47:58.000Z","size":51,"stargazers_count":48,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-14T21:42:44.781Z","etag":null,"topics":["ejs","javascript","templating"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mourner.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-05-14T14:03:14.000Z","updated_at":"2025-04-14T12:02:56.000Z","dependencies_parsed_at":"2024-10-12T00:05:59.863Z","dependency_job_id":"14a881ed-ea16-40a1-873b-edfe8626a719","html_url":"https://github.com/mourner/yeahjs","commit_stats":{"total_commits":25,"total_committers":1,"mean_commits":25.0,"dds":0.0,"last_synced_commit":"1e8bf23aabd776c4b25a146ccef2fd7e8812f6a0"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/mourner/yeahjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Fyeahjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Fyeahjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Fyeahjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Fyeahjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mourner","download_url":"https://codeload.github.com/mourner/yeahjs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Fyeahjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28552142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T20:59:07.572Z","status":"ssl_error","status_checked_at":"2026-01-18T20:59:02.799Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ejs","javascript","templating"],"created_at":"2024-09-28T07:21:14.154Z","updated_at":"2026-01-18T22:02:40.348Z","avatar_url":"https://github.com/mourner.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yeahjs\n\nA tiny, modern, fast implementation of EJS (Embedded JavaScript Templates). A nearly drop-in replacement for [`ejs`](https://ejs.co/) with a few [intentional limitations](#compared-to-ejs).\n\n[![Node](https://github.com/mourner/yeahjs/actions/workflows/node.yml/badge.svg)](https://github.com/mourner/yeahjs/actions/workflows/node.yml)\n[![Install Size](https://packagephobia.now.sh/badge?p=yeahjs)](https://packagephobia.now.sh/result?p=yeahjs)\n[![Min-zipped Size](https://badgen.net/bundlephobia/minzip/yeahjs)](https://bundlephobia.com/result?p=yeahjs)\n[![Simply Awesome](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects)\n\n## Example\n\n```ejs\n\u003cul\u003e\n\u003c% for (let word of locals.items) { -%\u003e\n  \u003cli\u003e\u003c%= word %\u003e\u003c/li\u003e\n\u003c% } -%\u003e\n\u003c/ul\u003e\n```\n\n```js\nimport {compile} from 'yeahjs';\n\nconst template = compile(ejs);\nconst output = template({items: ['flour', 'water', 'salt']});\n```\n\n```html\n\u003cul\u003e\n  \u003cli\u003eflour\u003c/li\u003e\n  \u003cli\u003ewater\u003c/li\u003e\n  \u003cli\u003esalt\u003c/li\u003e\n\u003c/ul\u003e\n```\n\n## Compared to `ejs`\n\nThere are a few key differences that allow `yeahjs` to be so small and fast:\n\n- **Strict mode** only (no `with` keyword in compiled functions).\n- Only **static path includes** (`include('header.ejs')`, but not `include(dir + file)`).\n- File handling **not included** — provide it with `read` and `resolve` options (see [example](#file-handling)).\n\nOtherwise `yeahjs` produces identical output to `ejs`.\n\n### Strict mode only\n\nThe `with` keyword has a very significant impact on performance in JavaScript, in addition to introducing hard to debug issues. Limiting `yeahjs` to strict mode makes sure it's always as fast and predictable as possible.\n\n### Static path includes\n\nStatic path includes make sure `yeahjs` can fully compile templates with includes at `compile` time, avoiding lazy compilation during template evaluation. This makes evaluation faster and more predictable.\n\n### Custom file handling\n\nNot including any file-system-specific code makes `yeahjs` environment-agnostic, having the same bundle for both Node and the browsers and giving full control over how includes get read and resolved.\n\n## Usage\n\n```js\nimport {compile} from 'yeahjs';\n\nconst template = compile(ejs, options);\n````\n\nReturns a function of the form `(data) =\u003e content`. Options:\n\n- `localsName`: the namespace to use for accessing template data (`locals` by default for `\u003c%= locals.foo %\u003e`).\n- `locals`: an array of variables to access directly (e.g. `['foo']` will allow `\u003c%= foo %\u003e` instead of `\u003c%= locals.foo %\u003e`).\n- `context`: an object to use as `this` in templates (`null` by default).\n- `escape`: a custom escaping function for values inside `\u003c%= ... %\u003e` (escapes XML by default).\n- `async`: if `true`, generates an async function to make it possible to use `await` inside templates (`false` by default).\n- `filename`: the file name of the template if present (used for resolving includes).\n- `read`: a function of the form `(filename) =\u003e content` for reading includes (e.g. from file system in Node).\n- `resolve`: a function of the form `(parentPath, includePath) =\u003e path` for resolving include paths.\n- `cache`: an object to cache compiled includes in for faster compilation; reuse between `compile` runs for best performance (`{}` by default).\n\n## EJS cheatsheet\n\n- `\u003c%= value %\u003e`: output the value (escaped).\n- `\u003c%- value %\u003e`: output the value (raw).\n- `\u003c% code %\u003e`: use arbitrary JavaScript.\n- `\u003c%_ code %\u003e`: use arbitrary JavaScript and strip whitespace on the same line before the tag.\n- `... _%\u003e`: strip whitespace and a single line break on the same line after the tag.\n- `... -%\u003e`: strip a single line break immediately after the tag.\n- `\u003c%%`, `%%\u003e`: output literal `\u003c%` or `%\u003e`.\n- `\u003c%# comment %\u003e`: comment (ignored).\n- `\u003c%- include('path/to/template.ejs', {foo: bar}) %\u003e`: include another template, optionally passing data.\n\n## File handling\n\nAn example of using `read`, `resolve` and `filename` options in Node.js to process includes:\n\n```js\nimport {readFileSync} from 'fs';\nimport {join, dirname} from 'path';\n\nconst template = yeahjs.compile(`\u003c%- include('../bar.html') %\u003e`, {\n    filename: 'foo/foo.html',\n    resolve: (parent, filename) =\u003e join(dirname(parent), filename),\n    read: filename =\u003e readFileSync(filename, 'utf8')\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmourner%2Fyeahjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmourner%2Fyeahjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmourner%2Fyeahjs/lists"}