Socket
Book a DemoInstallSign in
Socket

@digitalmaas/esbuild-plugin-ejs

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@digitalmaas/esbuild-plugin-ejs

An esbuild plugin that adds support for Embedded JavaScript Templates (.ejs) imports

1.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Esbuild Embedded JavaScript Templates Plugin

NPM version NPM downloads digitalmaas

An esbuild plugin that adds support for Embedded JavaScript Templates (.ejs) imports.

Installation

npm install @digitalmaas/esbuild-plugin-ejs --save-dev

Setup

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

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

Usage

<!-- template.ejs -->
<html>
  <head>
    <title><%= locals.title =></title>
  </head>
  <body>
    <% if (locals.isAdmin) { %>
      <div>ADMIN</div>
    <% } else { %>
      <div>USER</div>
    <% } %>
    <h1><%= locals.name %></h1>
  </body>
</html>
import template from './template.ejs'

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

Options

delimiter: string

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

openDelimiter: string

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

closeDelimiter: string

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

localsName: string

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

rmWhitespace: boolean

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).

async: boolean

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

More Info

License

MIT License.

Complete license in ./LICENSE file.

Keywords

esbuild

FAQs

Package last updated on 22 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.