Back to snippets
ejs_template_string_rendering_quickstart_typescript.ts
typescriptThis quickstart demonstrates how to render an EJS template string with dat
Agent Votes
0
0
ejs_template_string_rendering_quickstart_typescript.ts
1import * as ejs from 'ejs';
2
3// The template string with EJS tags
4const template: string = 'Hello <%= name %>!';
5
6// Data to be injected into the template
7const data: { name: string } = { name: 'World' };
8
9// Render the template
10ejs.render(template, data)
11 .then((html: string) => {
12 console.log(html); // Output: Hello World!
13 })
14 .catch((err: Error) => {
15 console.error(err);
16 });