Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fm-ph/rollup-plugin-twig
📃 Rollup plugin that imports pre-compiled Twig.js templates
https://github.com/fm-ph/rollup-plugin-twig
plugin rollup rollup-plugin templating twig
Last synced: 25 days ago
JSON representation
📃 Rollup plugin that imports pre-compiled Twig.js templates
- Host: GitHub
- URL: https://github.com/fm-ph/rollup-plugin-twig
- Owner: fm-ph
- License: mit
- Created: 2017-03-02T00:55:06.000Z (almost 8 years ago)
- Default Branch: develop
- Last Pushed: 2017-04-19T09:03:17.000Z (over 7 years ago)
- Last Synced: 2024-10-14T01:31:48.701Z (about 2 months ago)
- Topics: plugin, rollup, rollup-plugin, templating, twig
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome - twig - Import pre-compiled Twig.js templates. (Plugins / Templating)
README
# rollup-plugin-twig
[![build status][travis-image]][travis-url]
[![stability][stability-image]][stability-url]
[![npm version][npm-image]][npm-url]
[![js-standard-style][standard-image]][standard-url]
[![semantic-release][semantic-release-image]][semantic-release-url][Rollup](https://github.com/rollup/rollup) plugin that imports pre-compiled [Twig.js](https://github.com/twigjs/twig.js) templates.
## Installation
[![NPM](https://nodei.co/npm/rollup-plugin-twig.png)](https://www.npmjs.com/package/rollup-plugin-twig)
```sh
npm install rollup-plugin-twig --save-dev
```## Usage
Configure Rollup with `rollup-plugin-twig` :
```js
import { rollup } from 'rollup'
import twig from 'rollup-plugin-twig'rollup({
entry: 'src/main.js',
plugins: [
twig()
]
}).then(...)
```Create a template :
```html
{{ foo }}
```Import the template and render it with data (optional) :
```js
import template from './template.twig'const data = { foo: 'bar' }
console.log(template.render(data)) //bar
```## Options
Plugin options you can pass :
* `include` - Minimatch or array of minimatch with files that should be included by default.
* `exclude` - Minimatch or array of minimatch with files that should be excluded by default.
* `minify` - Minify the template (`true` by default).## Build
To build the sources with `rollup` in `./lib` directory :
```sh
npm run build
```## Testing
To run the tests, first clone the repository and install its dependencies :
```sh
git clone https://github.com/fm_ph/rollup-plugin-twig.git
cd rollup-plugin-twig
npm install
```Then, run the tests :
```sh
npm test
```To watch (test-driven development) :
```sh
npm run test:watch
```For coverage :
```sh
npm run test:coverage
```## License
MIT [License](LICENSE.md) © [Patrick Heng](http://hengpatrick.fr/) [Fabien Motte](http://fabienmotte.com/)
[travis-image]: https://img.shields.io/travis/fm-ph/rollup-plugin-twig/master.svg?style=flat-square
[travis-url]: http://travis-ci.org/fm-ph/rollup-plugin-twig
[stability-image]: https://img.shields.io/badge/stability-stable-brightgreen.svg?style=flat-square
[stability-url]: https://nodejs.org/api/documentation.html#documentation_stability_index
[npm-image]: https://img.shields.io/npm/v/rollup-plugin-twig.svg?style=flat-square
[npm-url]: https://npmjs.org/package/rollup-plugin-twig
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: https://github.com/feross/standard
[semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square
[semantic-release-url]: https://github.com/semantic-release/semantic-release