1.0.1 • Published 2 years ago

rollup-plugin-eta v1.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

rollup-plugin-eta Test Changes

Rollup.js template loader plugin for η (Eta). Supports loading of any files with proper Eta content.

Installation

Using NPM:

npm install eta rollup-plugin-eta --save-dev

or Yarn:

yarn add --dev eta rollup-plugin-eta

Usage

Create a rollup.config.js configuration file and import the plugin:

// rollup.config.js
import eta from 'rollup-plugin-eta';

rollup({
    entry: 'main.js',
    output: [
        {
            dir: 'dist',
            format: 'esm'
        },
    ],
    plugins: [
        eta({
            include: ['**/*.eta', '**/*.html'], // optional, '**/*.eta' by default
            exclude: ['**/index.html'], // optional, undefined by default
            data: {
                name: 'John Doe'
            }, // optional, default template data
            etaConfig: {
                tags: ['<%', '%>']
            } // optional, eta configuration
        }),
    ],
});

In your app you can then import your template and render its content, e.g.:

// main.js
import tpl from './tpl.eta';
console.log(tpl({ age: 42 }));

If your template file (tpl.eta) looks as follows:

<p>Hello 👋 , my name is <%= it.name %> and I am <%= it.age %> year old ✨</p>

Then, your compiled file would return:

$ node ./dist/main.js
<p>Hello 👋 , my name is John Doe and I am 42 year old ✨</p>

Options

The following options are unique to rollup-plugin-eta:

include

Type: String | Array[...String] Default: ['**/*.eta']

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should operate on. By default all **/*.eta files are targeted.

exclude

Type: String | Array[...String] Default: []

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no files are ignored.

data

Type: Object Default: null

A default set of data inputs for the template.

etaConfig

Type: Object Default: null

The default Eta configuration object (Eta.config).

Contribute

You have an idea on how to improve the package, please send us a pull request! Have a look into our contributing guidelines.

Getting Help

Running into issues or are you missing a specific usecase? Feel free to file an issue.


1.0.1

2 years ago

1.0.0

2 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago