Home

Awesome

dejs

Build Status

Features

Supported

Not supported

Usage

import * as dejs from "https://deno.land/x/dejs@0.10.3/mod.ts";

Render from file

<body>
  <% if (name) { %>
    <h1>hello, <%= name %>!</h1>
  <% } %>
</body>
const { cwd, stdout, copy } = Deno;
import { renderFile } from "https://deno.land/x/dejs/mod.ts";

const output = await renderFile(`${cwd()}/template.ejs`, {
  name: "world",
});
await copy(output, stdout);
$ deno index.ts
<body>

    <h1>hello, world!</h1>

</body>

Render from string

const { cwd, stdout, copy } = Deno;
import { render } from "https://deno.land/x/dejs/mod.ts";

const template = `<body>
  <% if (name) { %>
    <h1>hello, <%= name %>!</h1>
  <% } %>
</body>`;

const output = await render(template, {
  name: "world",
});
await copy(output, stdout);

Include partial ejs template

Usage

await include(filePath, params)

Example

<html>
<head>
  <title><%- title %></title>
</head>
<body>
</body>
</html>
<%- await include('views/header.ejs', { title: 'include example' }) %>
<h1>hello, world!</h1>
<%- await include('views/footer.ejs') %>
const { cwd, stdout, copy } = Deno;
import { renderFile } from "https://deno.land/x/dejs/mod.ts";

const output = await renderFile(`${cwd()}/views/main.ejs`);
await copy(output, stdout);
$ deno index.ts
<html>
<head>
  <title>include example</title>
</head>
<body>
<h1>hello, world!</h1>
</body>
</html>

Limitations

Development

Update modules

dem update https://deno.land/std@v0.xx.x

Lint

Format

Testing

Author

syumai

License

MIT