jstransformer-reshape
v1.0.0
Published
Reshape support for JSTransformers.
Downloads
8
Readme
jstransformer-reshape
reshape support for JSTransformers.
Installation
npm install jstransformer-reshape
Note: Reshape requires node v6 or above.
API
const reshape = require('jstransformer')(require('jstransformer-reshape'))
const customElements = require('reshape-custom-elements')
const expressions = require('reshape-expressions')
const text = `
<my-component>
<my-text class="text">{{ name }}</my-text>
</my-component>
`
const locals = {
name: 'caleb'
}
// pass an array of plugins
const options = { plugins: [customElements(), expressions()] }
reshape.renderAsync(text, options).then((result) => {
console.log(result.body)
})
//=> '<div class="my-component">\n<div class="text my-text">Caleb</div>\n</div>'
// or pass an object of plugins and settings
const options2 = {
plugins: {
customElements: { defaultTag: 'span' },
expressions: {}
}
}
reshape.renderAsync(text, options2, locals).then(function (result) {
console.log(result.body)
})
//=> '<span class="my-component">\n<span class="text my-text">Caleb</span>\n</span>'
License
MIT