Skip to content

An additive string to ES6 template string converter

Notifications You must be signed in to change notification settings

Maxobat/templatize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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}`

About

An additive string to ES6 template string converter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published