0.1.0 • Published 4 years ago

@zendo.p/babel-plugin-transform-template-literals v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

babel-plugin-transform-template-literals

Support new option stripForeAndAftLinebreaks, for detail:

stripForeAndAftLinebreaks:
  "none" // None
  "all"  // Strip fore-and-aft /^[\n|\t|\s]+|[\n|\t|\s]+$/
  "default"  // Strip fore-and-aft /^[\n]|[\n]$/

babel.config.js/.babelrc configuration

{
  plugins: [
    [
      require('babel-plugin-transform-template-literals'),
      {
        // ['none', 'default', 'all'], default: 'default'
        stripForeAndAftLinebreaks: 'none'
      }
    ]
  ]
}

samples

stripForeAndAftLinebreaks: none

/** ES6 */
let a = `

abc
`

/** ES5 */
var a = '\n\nabc\n'

stripForeAndAftLinebreaks: default

/** ES6 */
let a = `

abc
`

/** ES5 */
var a = '\nabc'

stripForeAndAftLinebreaks: all

/** ES6 */
let a = `

abc
`

/** ES5 */
var a = 'abc'

Using plugin

npm install -D babel-plugin-transform-template-literals

or

yarn add -D babel-plugin-transform-template-literals

Fork: https://github.com/babel/babel/tree/v7.8.6/packages/babel-plugin-transform-template-literals

@babel/plugin-transform-template-literals

Compile ES2015 template literals to ES5

See our website @babel/plugin-transform-template-literals for more information.

Install

Using npm:

npm install --save-dev @babel/plugin-transform-template-literals

or using yarn:

yarn add @babel/plugin-transform-template-literals --dev