Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ejs-loader

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ejs-loader

EJS (Underscore/LoDash Templates) loader for webpack

  • 0.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
140K
increased by10.42%
Maintainers
2
Weekly downloads
 
Created

What is ejs-loader?

The ejs-loader npm package is a loader for webpack that allows you to compile EJS (Embedded JavaScript) templates into JavaScript functions. This is particularly useful for integrating EJS templates into a webpack-based build process, enabling you to use EJS templates in your client-side code.

What are ejs-loader's main functionalities?

Basic EJS Template Loading

This feature allows you to load and compile an EJS template using webpack. The compiled template can then be used as a function that takes a data object and returns the rendered HTML.

const template = require('ejs-loader!./template.ejs');
const html = template({ name: 'World' });
console.log(html);

Custom EJS Options

This feature allows you to pass custom options to the EJS compiler via query parameters in the require statement. In this example, the 'variable' option is set to 'data'.

const template = require('ejs-loader?variable=data!./template.ejs');
const html = template({ name: 'World' });
console.log(html);

Using EJS with Webpack

This feature demonstrates how to configure webpack to use ejs-loader for all .ejs files. This setup allows you to import EJS templates in your JavaScript files without specifying the loader each time.

module.exports = {
  module: {
    rules: [
      {
        test: /\.ejs$/,
        use: 'ejs-loader'
      }
    ]
  }
};

Other packages similar to ejs-loader

Keywords

FAQs

Package last updated on 10 Jun 2020

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc