import * as dejs from "https://deno.land/x/[email protected]/mod.ts";
renderFile
(filePath: string, params: Params): Promise<Deno.Reader>
render
(body: string, params: Params): Promise<Deno.Reader>
renderFileToString
(filePath: string, params: Params): Promise<string>
renderToString
(body: string, params: Params): Promise<string>
compile
(reader: Reader): Promise<Template>
Template(params: Params): string
<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>
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
function in ejs.include
resolves views from relative path from executed ts / js file.await include(filePath, params)
<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>
dem update https://deno.land/[email protected]
make lint
make fmt
make test
syumai
MIT