Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xuxinhang/snowpack-plugin-ejs
Add the support for EJS template engine to Snowpack.
https://github.com/xuxinhang/snowpack-plugin-ejs
ejs plugin snowpack
Last synced: about 2 months ago
JSON representation
Add the support for EJS template engine to Snowpack.
- Host: GitHub
- URL: https://github.com/xuxinhang/snowpack-plugin-ejs
- Owner: xuxinhang
- License: mit
- Created: 2021-03-07T14:48:25.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-02T15:56:54.000Z (over 3 years ago)
- Last Synced: 2024-10-21T00:44:44.872Z (2 months ago)
- Topics: ejs, plugin, snowpack
- Language: EJS
- Homepage:
- Size: 22.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# snowpack-plugin-ejs
Bring the power of EJS to Snowpack.--------
## Quick Start
This plugin adds support for the EJS template engine to Snowpack.
Use `npm` to install it first.
```bash
npm i -D snowpack-plugin-ejs
```Modify your snowpack config file to enable `snowpack-plugin-ejs`. You can also add plugin options if you want.
```javascript
{
plugins: [
['snowpack-plugin-ejs'],
],
}// or... assign render data
{
plugins: [
['snowpack-plugin-ejs', {
renderData: {
nickname: 'Calf',
},
}],
],
}```
## Example
There is [an example](./example/snowpack.config.js) about how to use `snowpack-plugin-ejs` in `./example` directory.
## Plugin Options
#### `ejsModule`
*optional*
Assign this option to use your own ejs module.
This option would be useful when you have to rewrite some members of ejs module.
```javascript
let ejs = require('ejs'),
ejs.cache = require('lru-cache')(100);module.exports = {
plugins: [
['snowpack', { ejsModule: ejs }],
],
};
```#### `renderOptions`
`Object` | `Function`: *optional*
Provide options which EJS renderer uses. See [EJS's document](https://ejs.co/#docs) for all acceptable items.
```js
{
renderOptions: { rmWhitespace: true },
}
```
A function can also be provided, whose first argument is same to that of [Snowpack's `load` hook](https://www.snowpack.dev/guides/plugins#example%3A-build-from-source). This function should return the actually option value.
```js
{
renderOptions: ({ filePath }) => ({
delimiter: filePath.includes('.obs.ejs') ? '?' : undefined,
}),
}
```#### `renderData`
`Object` | `Function`: *optional*
Assign data to render templates. The data will only be passed to the *root* template, that is, the data cannot inject into the *included* templates.
```js
{
renderData: { nickname: 'Calf' },
}
```
A function can also be provided, whose first argument is same to that of [Snowpack's `load` hook](https://www.snowpack.dev/guides/plugins#example%3A-build-from-source). This function should return the actually option value.