@digitalmaas/esbuild-plugin-ejs (original) (raw)

import esbuild from 'esbuild' import ejsPlugin from '@digitalmaas/esbuild-plugin-ejs'

await esbuild.build({ /* all of your config /, plugins: [ ejsPlugin({ / ejs options */ }), ] })

<%= locals.title => <% if (locals.isAdmin) { %>
ADMIN
<% } else { %>
USER
<% } %>

<%= locals.name %>

import template from './template.ejs'

const templateAsString = template({ isAdmin: false, title: 'Doc Title', name: 'Cool Test' })

Character to use for inner delimiter. Defaults to '%'.

Character to use for opening delimiter. Defaults to '<'.

Character to use for closing delimiter. Defaults to '>'.

Name to use for the object storing local variables. Defaults to locals.

Remove all safe-to-remove whitespace, including leading and trailing whitespace. It also enables a safer version of `-%>`` line slurping for all scriptlet tags (it does not strip new lines of tags in the middle of a line).

When true, EJS will use an async function for rendering.

MIT License.