Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rspack-contrib/rsbuild-plugin-ejs
An Rsbuild plugin to provide support for the EJS template engine.
https://github.com/rspack-contrib/rsbuild-plugin-ejs
ejs rsbuild rsbuild-plugin rspack
Last synced: 3 months ago
JSON representation
An Rsbuild plugin to provide support for the EJS template engine.
- Host: GitHub
- URL: https://github.com/rspack-contrib/rsbuild-plugin-ejs
- Owner: rspack-contrib
- License: mit
- Created: 2024-08-23T02:31:50.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-08T01:21:47.000Z (4 months ago)
- Last Synced: 2024-09-28T07:20:26.365Z (3 months ago)
- Topics: ejs, rsbuild, rsbuild-plugin, rspack
- Language: TypeScript
- Homepage:
- Size: 38.1 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rspack - rsbuild-plugin-ejs
README
# rsbuild-plugin-ejs
An Rsbuild plugin to provide support for the [EJS](https://github.com/mde/ejs) template engine.
## Usage
Install:
```bash
npm add rsbuild-plugin-ejs -D
```Add plugin to your `rsbuild.config.ts`:
```ts
// rsbuild.config.ts
import { pluginEjs } from "rsbuild-plugin-ejs";export default {
plugins: [pluginEjs()],
};
```### Using EJS Templates
After the plugin registration is completed, Rsbuild will automatically parse template files with the `.ejs` extension and compile them using the EJS template engine.
For example, first create a `src/index.ejs` file, and point to that file using `html.template`:
```ts title="rsbuild.config.ts"
export default {
html: {
template: "./src/index.ejs",
},
};
```Then, you can use EJS syntax in the `index.ejs` template:
```html
Hello <%= foo %>!
Hello Rsbuild!
```Refer to the [EJS documentation](https://github.com/mde/ejs) for more details.
## Options
### ejsOptions
Used to set the compilation options for EJS. For detailed options, please refer to the [EJS API Reference](https://ejs.co/#docs).
- **Type:** `import('ejs').Options`
- **Default:**```ts
const defaultOptions = {
filename,
};
```- **Example:**
```ts
pluginEjs({
ejsOptions: {
delimiter: "|",
},
});
```## License
[MIT](./LICENSE).