{"id":18831279,"url":"https://github.com/acrazing/ejs-stream","last_synced_at":"2025-04-14T04:16:11.272Z","repository":{"id":37934385,"uuid":"214584630","full_name":"acrazing/ejs-stream","owner":"acrazing","description":"A nodejs stream template renderer based on ejs syntax.","archived":false,"fork":false,"pushed_at":"2023-01-04T22:33:45.000Z","size":338,"stargazers_count":10,"open_issues_count":16,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T04:16:07.162Z","etag":null,"topics":["ejs","ejs-stream","stream"],"latest_commit_sha":null,"homepage":null,"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/acrazing.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}},"created_at":"2019-10-12T05:35:31.000Z","updated_at":"2024-10-17T21:30:41.000Z","dependencies_parsed_at":"2023-02-02T22:16:54.519Z","dependency_job_id":null,"html_url":"https://github.com/acrazing/ejs-stream","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/acrazing%2Fejs-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acrazing%2Fejs-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acrazing%2Fejs-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acrazing%2Fejs-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acrazing","download_url":"https://codeload.github.com/acrazing/ejs-stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819408,"owners_count":21166477,"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":["ejs","ejs-stream","stream"],"created_at":"2024-11-08T01:52:52.023Z","updated_at":"2025-04-14T04:16:11.253Z","avatar_url":"https://github.com/acrazing.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ejs-stream2\n\nA nodejs stream template renderer based on ejs syntax.\n\nThe library [ejs](https://github.com/mde/ejs) supports `string` only to output,\nbut we need to output stream sometimes(see [#102](https://github.com/mde/ejs/issues/102)).\nFor example, with `React`'s`renderToNodeStream` API. This library makes it possible.\n\n## Install\n\nPlease note the package name is **`ejs-stream2`** rather than `ejs-stream` in\nnpm, for `ejs-stream` is occupied by another people.\n\n```bash\nnpm install ejs-stream2\n\n# or var yarn\nyarn add ejs-stream2\n```\n\n## Usage\n\n```typescript jsx\nimport { compile } from 'ejs-stream2';\nimport express from 'express';\nimport { renderToNodeStream } from 'react-dom/server';\n\nconst template = compile(`\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n\u003ctitle\u003e\u003c%= title %\u003e\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cdiv id=root\u003e\u003c%- content %\u003e\u003c/div\u003e\n\u003cscript async defer src=\"\u003c%- scriptBundle %\u003e\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n`);\n\nconst app = express();\napp.get('/', (req, res) =\u003e {\n  const stream = template({\n    title: 'Hello world',\n    content: renderToNodeStream(\u003cApp /\u003e),\n    scriptBundle: '/bundle.js',\n  });\n  // please note you must listen the `error` event of `Readable`, or your\n  // application with exit if error occurs.\n  stream.on('error', (error) =\u003e {\n    console.error(error);\n    res.end();\n  });\n  stream.pipe(res);\n});\n```\n\n## Features\n\n- Support all the syntax set of `ejs`, see [syntax.md](https://github.com/mde/ejs/blob/master/docs/syntax.md)\n- Support the following variables to output directly by `\u003c%- variable %\u003e` or `\u003c%= variable %\u003e`\n  - `NodeJS.ReadableStream | Uint8Array | string`\n  - `Promise\u003cNodeJS.ReadableStream | Uint8Array | string\u003e`\n  - `Array\u003cNodeJS.ReadableStream | Uint8Array | string | Promise\u003cNodeJS.ReadableStream | Uint8Array | string\u003e\u003e`\n\n_For simplify the test cases, we removed the following features from `ejs`_\n\n1. file system relative features, such as `renderFile`, `include`\n2. options to change delimiters\n3. `async` mode\n4. cache\n\n## LICENSE\n\nThis project is published under `MIT` license\n\n    The MIT License (MIT)\n\n    Copyright (c) 2019 acrazing\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n    SOFTWARE.\n\nmost code of the compiler comes from [mde/ejs](https://github.com/mde/ejs),\nlicense of this project at \u003chttps://github.com/mde/ejs/blob/master/LICENSE\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facrazing%2Fejs-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facrazing%2Fejs-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facrazing%2Fejs-stream/lists"}