{"id":13485120,"url":"https://github.com/syumai/dejs","last_synced_at":"2025-05-06T21:29:50.058Z","repository":{"id":33943494,"uuid":"163327891","full_name":"syumai/dejs","owner":"syumai","description":"ejs template engine for deno.","archived":false,"fork":false,"pushed_at":"2023-05-30T01:25:31.000Z","size":94,"stargazers_count":147,"open_issues_count":4,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-31T03:11:15.449Z","etag":null,"topics":["deno","ejs","typescript"],"latest_commit_sha":null,"homepage":"","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/syumai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-12-27T19:08:55.000Z","updated_at":"2024-11-28T13:19:33.000Z","dependencies_parsed_at":"2024-01-05T21:00:10.803Z","dependency_job_id":"cf1c35ac-9a60-4596-9853-2c45820a58a2","html_url":"https://github.com/syumai/dejs","commit_stats":{"total_commits":100,"total_committers":6,"mean_commits":"16.666666666666668","dds":0.08999999999999997,"last_synced_commit":"0cb4413ec32433990b97553c9bbe8be5b83ac3e8"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syumai%2Fdejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syumai%2Fdejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syumai%2Fdejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syumai%2Fdejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syumai","download_url":"https://codeload.github.com/syumai/dejs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252771738,"owners_count":21801772,"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":["deno","ejs","typescript"],"created_at":"2024-07-31T17:01:46.757Z","updated_at":"2025-05-06T21:29:50.037Z","avatar_url":"https://github.com/syumai.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","基础设施","Uncategorized","Modules","Libraries"],"sub_categories":["Deno 源","Uncategorized","Online Playgrounds","Assistants","Template engine"],"readme":"# dejs\n\n[![Build Status](https://github.com/syumai/dejs/workflows/test/badge.svg?branch=master)](https://github.com/syumai/dejs/actions)\n\n- [ejs](https://ejs.co) template engine for\n  [deno](https://github.com/denoland/deno).\n\n## Features\n\n### Supported\n\n- \u003c%= %\u003e Output escaped value\n- \u003c%- %\u003e Output raw value\n- \u003c%# %\u003e Comment (nothing will be shown)\n- \u003c% %\u003e Evaluate (use control flow like: if, for)\n- include partial ejs template\n\n### Not supported\n\n- All other features of ejs\n\n## Usage\n\n```ts\nimport * as dejs from \"https://deno.land/x/dejs@0.10.3/mod.ts\";\n```\n\n- **`renderFile`** `(filePath: string, params: Params): Promise\u003cDeno.Reader\u003e`\n  - renders from file, outputs Deno.Reader\n- **`render`** `(body: string, params: Params): Promise\u003cDeno.Reader\u003e`\n  - renders from string, outputs Deno.Reader\n- **`renderFileToString`** `(filePath: string, params: Params): Promise\u003cstring\u003e`\n  - renders from file, outputs string\n- **`renderToString`** `(body: string, params: Params): Promise\u003cstring\u003e`\n  - renders from string, outputs string\n- **`compile`** `(reader: Reader): Promise\u003cTemplate\u003e`\n  - only compiles ejs and returns `Template(params: Params): string`\n  - use this to cache compiled result of ejs\n\n### Render from file\n\n- template.ejs\n\n```ejs\n\u003cbody\u003e\n  \u003c% if (name) { %\u003e\n    \u003ch1\u003ehello, \u003c%= name %\u003e!\u003c/h1\u003e\n  \u003c% } %\u003e\n\u003c/body\u003e\n```\n\n- index.ts\n\n```ts\nconst { cwd, stdout, copy } = Deno;\nimport { renderFile } from \"https://deno.land/x/dejs/mod.ts\";\n\nconst output = await renderFile(`${cwd()}/template.ejs`, {\n  name: \"world\",\n});\nawait copy(output, stdout);\n```\n\n- console\n\n```sh\n$ deno index.ts\n\u003cbody\u003e\n\n    \u003ch1\u003ehello, world!\u003c/h1\u003e\n\n\u003c/body\u003e\n```\n\n### Render from string\n\n```ts\nconst { cwd, stdout, copy } = Deno;\nimport { render } from \"https://deno.land/x/dejs/mod.ts\";\n\nconst template = `\u003cbody\u003e\n  \u003c% if (name) { %\u003e\n    \u003ch1\u003ehello, \u003c%= name %\u003e!\u003c/h1\u003e\n  \u003c% } %\u003e\n\u003c/body\u003e`;\n\nconst output = await render(template, {\n  name: \"world\",\n});\nawait copy(output, stdout);\n```\n\n### Include partial ejs template\n\n- To include template from other file, use `include` function in ejs.\n- `include` resolves views from relative path from **executed ts / js file**.\n  (not from ejs template file).\n  - This behavior may change in the future.\n\n#### Usage\n\n```ejs\nawait include(filePath, params)\n```\n\n#### Example\n\n- views/header.ejs\n\n```ejs\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003e\u003c%- title %\u003e\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n```\n\n- views/footer.ejs\n\n```ejs\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n- views/main.ejs\n\n```\n\u003c%- await include('views/header.ejs', { title: 'include example' }) %\u003e\n\u003ch1\u003ehello, world!\u003c/h1\u003e\n\u003c%- await include('views/footer.ejs') %\u003e\n```\n\n- index.ts\n\n```ts\nconst { cwd, stdout, copy } = Deno;\nimport { renderFile } from \"https://deno.land/x/dejs/mod.ts\";\n\nconst output = await renderFile(`${cwd()}/views/main.ejs`);\nawait copy(output, stdout);\n```\n\n- console\n\n```sh\n$ deno index.ts\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003einclude example\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003ch1\u003ehello, world!\u003c/h1\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Limitations\n\n- backslashes at line end will removed.\n\n## Development\n\n### Update modules\n\n- Please use [dem](https://github.com/syumai/dem)\n\n```\ndem update https://deno.land/std@v0.xx.x\n```\n\n### Lint\n\n- `make lint`\n\n### Format\n\n- `make fmt`\n\n### Testing\n\n- `make test`\n\n## Author\n\nsyumai\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyumai%2Fdejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyumai%2Fdejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyumai%2Fdejs/lists"}