Plugins

Introduction

A plugin is a class that provides specific low-level functionality which is configured and installed at runtime. This makes it possible to extend the EJS without modifying the core library.

Plugins are intended to provide environment-wide functionality, and should therefore be carefully considered on a per-application basis. Specific application features should be developed as modules, instead.

Modules which depend on plugins are inherently less portable. Ensure that modules which are shared across applications do not depend on plugins that are not available in all of the applications.

When should I use a plugin?

TL;DR Whenever you find yourself wanting to edit the core EJS library, you should make a plugin instead.

A plugin is best for providing low-level functionality that is specific to one or more related applications but that isn't abstract enough to belong in the core library.

Additionally, plugins are the ideal mechanism for integrating with third-party libraries and their ecosystems (e.g. Vue or jQuery). This allows EJS to continue without any dependencies of its own while providing modules with access to third-party libraries if they are necessary for a given application.

Last updated