templatize-string

1.0.5 • Public • Published

Templatize

Convert additive strings to ES6 template strings.

Example

    'this ' + 'is ' + 'a ' + 'string. ' + testVariable + (testVariable ? 'foo' : 'bar')

Compiles to

    `this is a string. ${testVariable}${(testVariable ? 'foo' : 'bar')}`

Usage

    const templatize = require('templatize-string');
    const foo = 'bar';

    let templatized = templatize('foo is equal to ' + foo).renderWrapped(); // Will return `foo is equal to ${foo}`

Methods

render

Returns templatized string.

    let templatized = templatize('foo is equal to ' + foo).render(); // Will return 'foo is equal to ${foo}'

renderWrapped

Arguments:

  • wrappingChar - The character the rendered string will be wrapped in. Default is `.

Returns templatized string wrapped with the specified character.

    let templatized = templatize('foo is equal to ' + foo).renderWrapped(); // Will return `foo is equal to ${foo}`

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.5
    2
    • latest

Version History

Package Sidebar

Install

npm i templatize-string

Weekly Downloads

1

Version

1.0.5

License

MIT

Last publish

Collaborators

  • maxobat