templatize-string
v1.0.5
Published
Convert additive strings to ES6 template strings.
Downloads
16
Readme
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}`