0.0.1 • Published 5 years ago
alpine-inline-transpile v0.0.1
Alpine.js Inline Transpile
Transpile inline Alpine.js directive code
Installation
alpine-inline-transpile is a PostHTML plugin.
You can install it as follows (ignore posthtml if it's already installed).
npm install --save-dev alpine-inline-transpile posthtml
# or
yarn add --dev alpine-inline-transpile posthtmlUsage
const posthtml = require('posthtml');
const inline = require('alpine-inline-transpile');
// `target` is an ECMAScript version
// see https://swc-project.github.io/docs/configuring-swc#jsctarget
posthtml([inline({target: 'es5'})])
.process(
`<div x-data="{ show: false }">
<button @click="show = !show">
Toggle
</button>
<div x-show="show">
Can be toggled
</div>
</div>`
)
.then(({html}) => {
// Do something with the HTML
console.log(html);
});Options
target: the ECMAScript version to target (see https://swc-project.github.io/docs/configuring-swc#jsctarget), for IE11 use "es5"
Requirements
- Node 10
- Yarn 1.x or npm
Setup
- Clone the repository
- Run
yarnornpm installinstalls all required dependencies.
npm scripts
Equivalent
npm run <script>should also work
yarn testwill run tests with uvuyarn lintwill lint all of the files with xoyarn fmtwill run lint with--fixoption on all the examples files (and tests).
LICENSE
Code is licensed under the MIT License.
0.0.1
5 years ago