1.2.3 • Published 6 years ago

language-strings v1.2.3

Weekly downloads
5
License
WTFPL
Repository
github
Last release
6 years ago

Language Strings

Build Status Coverage Status

Interpolate safely in several languages using ES6 template literals.

const strings = require('language-strings')

strings.html`<div>${unsafeValue}</div>`
strings.shell`echo ${unsafeValue} | xargs...`
strings.css`content: "${unsafeValue}"`
strings.css`background: url(data:image/svg+xml,${svg})`
strings.url`/foo/bar/${valueWithMaybeSlashes}`

You can also require the functions individually to save space if you're writing frontend code.

const html = require('language-strings/html')

html`<span>${unsafeValue}</span>`

You can mark unsafe values that are to be put directly into the string by using require('language-strings').unsafe or require('language-strings/unsafe')()

const html = require('language-strings/html')
const unsafe = require('language-strings/unsafe')

html`<title>${"hello world"}</title><body>${unsafe(userInput)}</body>`
1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

7 years ago