# ejs-simple-loader

> basic ejs loader for webpack

Latest version **0.1.1** (published 2017-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install ejs-simple-loader
pnpm add ejs-simple-loader
yarn add ejs-simple-loader
bun add ejs-simple-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-06-08 |
| First published | 2017-02-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+5 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 8 |
| Author | sookiwi |
| Maintainers | carlsagan21 |
| Keywords | ejs, webpack, loader |

## Links

- npm: https://www.npmjs.com/package/ejs-simple-loader
- Repository: https://github.com/carlsagan21/ejs-simple-loader
- Homepage: https://github.com/carlsagan21/ejs-simple-loader#readme
- Issues: https://github.com/carlsagan21/ejs-simple-loader/issues
- npm.io page: https://npm.io/package/ejs-simple-loader

## Dependencies (2)

- [ejs](https://npm.io/package/ejs.md) 2.5.6
- [loader-utils](https://npm.io/package/loader-utils.md) 1.0.2

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2017-06-08
- 0.1.0 — 2017-02-26
- 0.0.3 — 2017-02-26
- 0.0.2 — 2017-02-25
- 0.0.1 — 2017-02-25

## README

# ejs-simple-loader

basic ejs loader for webpack

## Examples

```javascript
// simple usage
require('ejs-simple!./path/to/file.ejs')
// with data as params
require('ejs-simple?key=value!./path/to/file.ejs')
```

`{loader}!file.ext` syntax of webpack is one of the common way to use loader.

Personally, I combined `ejs-simple-loader` with [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) to make html and insert javascript on it.

```javascript
// with html-webpack-plugin
new HtmlWebpackPlugin({
  title: template,
  filename: template + '.html',
  template: 'ejs-simple?title=' + template + '&distPath=' + DIST_PATH + '!src/templates/' + template + '.ejs',
  chunks: ['landing'],
  distPath: DIST_PATH
})
```

so it goes as followes:  ejs -> html -> javascript inserted html

```html
<!-- Use include syntax -->
<!-- Use filenames relative to working dir. -->
<div>
  <%- include('./header', {locale: locale}) %>
</div>
```

If it is used with html-webpack-plugin, the path is relative to the location of mother template. so if templates are stored in same directory, './filename' is enough.

##### webpack1 globalOptions

```javascript
// also can pass params with global options
config.ejsSimpleLoader = {
  key: 'test',
  title: template,
  distPath: DIST_PATH
}
```

##### Known Issues

-   a possible problem with webpack2 `rules.use.loader`. I recommand you to use this with `html-webpack-plugin`.

## Installation

```shell
npm install --save ejs-simple-loader
```

## Purpose

I know there are several ejs loader available. [ejs-loader](https://github.com/okonet/ejs-loader), [ejs-compiled-loader](https://github.com/bazilio91/ejs-compiled-loader), [ejs-render-loader](https://www.npmjs.com/package/ejs-render-loader) have already existed and still works.

But, [ejs-loader](https://github.com/okonet/ejs-loader) use `lodash` instead of *de facto* official [ejs](https://github.com/mde/ejs).  
[ejs-compiled-loader](https://github.com/bazilio91/ejs-compiled-loader) have problem with `<%- include('header') %>` syntax. it works in `<%- include header %>` syntax form, which is still supported, but seems to fail on more [recent syntax](https://github.com/mde/ejs#includes). And also too many unnecessary dependencies like `html-minifier`, `merge`, and `uglify-js`.  
[ejs-render-loader](https://www.npmjs.com/package/ejs-render-loader) performs perfectly, but I couldn't find repo of it. Only [npm package](https://www.npmjs.com/package/ejs-render-loader) seems to exist.

[html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) supports ejs or other template engines by itself. However `include` syntax is not possible.

And all of them are not actively updated. I'm not promising eternal maintenance of this library, but rather will do my best. ;)

### License

ejs-simple-loader is MIT licensed.

---
_Source: https://npm.io/package/ejs-simple-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
