Skip to content

jstransformers/jstransformer-reshape

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jstransformer-reshape

reshape support for JSTransformers.

Build Status Coverage Status Dependency Status NPM version

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