Skip to content

Webpack loader for rendering HTML from EJS templates

License

Notifications You must be signed in to change notification settings

smcelhinney/ejs-html-loader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ejs-html-loader

Version License Build Coverage Dependencies

Webpack loader for rendering plain HTML from EJS template files

Install

Install with npm. And be sure to install EJS and Webpack, which are peer dependencies.

npm install --save-dev webpack ejs ejs-html-loader

Usage

In your Webpack configuration, options and locals can be passed to EJS in two ways. First, through a query string or query object:

module.exports = {
  // ...
  module: {
    loaders: [{
      test: /\.ejs$/,
      loader: 'ejs-html?title=The%20Big%20Gatsby&production'
    }]
  }
};

Or second, via an 'ejsHtml' property:

module.exports = {
  // ...
  ejsHtml: {
    title: 'For Whom the Bell Rings',
    baseUrl: '/',
    delimiter: '?'
  }
};

Options

All properties passed to the loader will be available to your templates as local variables. In addition, the following EJS options may be set:

  • context : object
    The value of this in your templates. If specified, its properties will be available in your templates, e.g. <%= this.somePropery %>.

  • delimiter : string='%'
    Character used inside of angle brackets marking opening/closing tags. Defaults to '%', as in <%= some.variable %>.

Includes

The EJS filename option is set automatically, so you may include partials relative to your template files. If you want your included files to automatically recompile in watch mode, be sure to use the following syntax:

<% include some/file %>

License

Copyright © 2016 Akim McMath. Licensed under the MIT License.

About

Webpack loader for rendering HTML from EJS templates

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CoffeeScript 63.7%
  • JavaScript 36.3%