一覧へ戻る
jawish/rollup-plugin-twig(新しいタブで開きます)
主要言語: JavaScript
- star 数
- 2
- watcher 数
- 1
- fork 数
- 0
- issue 数
- 0
- 最終更新
- 2019/04/28
主要言語: JavaScript
Rollup plugin that pre-compiles Twig.js templates.
NPM:
npm install --save-dev rollup-plugin-twig
Yarn:
yarn add --dev rollup-plugin-twig
Update rollup.config.js:
import { rollup } from 'rollup'; import strip from 'rollup-plugin-twig'; export default { input: 'src/index.js', output: [ { format: 'cjs', file: 'dist/my-lib.cjs.js' } ], plugins: [ twig() ] };
Create your Twig template files *.twig. e.g.:
<div>{{ name }}</div>
Import your Twig templates where needed. e.g:
import template from './template.twig' const data = { name: 'John Doe' } console.log(template.render(data)) // <div>John Doe</div>
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 using html-minifier. Default: true.
minifyOptions
Options to configure html-minifier.
Default options:
{ removeComments: true, collapseWhitespace: true, collapseBooleanAttributes: true, decodeEntities: true, html5: true, keepClosingSlash: true, minifyCSS: true, minifyJS: true, minifyURLs: true, }
MIT License