Skip to content

Babel plugin that will join strings and template strings in compilation time whenever it's possible.

License

Notifications You must be signed in to change notification settings

laysent/babel-plugin-transform-string-join

Repository files navigation

babel-plugin-transform-string-join

Build Status

Babel plugin that will join strings and template strings in compilation time whenever it's possible.

Examples

Array.proptotype.join

You can use Array.proptotype.join to join list of strings and template strings together.

In

const className = 'container';
const html = [
  `<div class=${className}>`,
    '<span>Hello World</span>',
  '</div>',
].join('');

Out

const html = `<div class=${className}><span>Hello World</span></div>`;

String addition

Also, you can use + to simply concat strings and template strings together.

In

const className = 'container';
const html =
  `<div class=${className}>` +
    '<span>Hello World</span>' +
  '</div>';

Out

const html = `<div class=${className}><span>Hello World</span></div>`;

Installation

$ npm install babel-plugin-transform-string-join

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-string-join"]
}

Via CLI

$ babel --plugins transform-string-join script.js

Via Node API

require('babel-core').transform('code', {
  plugins: ['transform-string-join']
});

License

MIT

About

Babel plugin that will join strings and template strings in compilation time whenever it's possible.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published