0.0.3 • Published 4 years ago

maybe-include v0.0.3

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

maybe-include

Include a string in a template literal, if a condition is truthy

Installation

npm install --save maybe-include

Usage

import maybe from 'maybe-include'

const food = 'sushi'
const drink = 'tea'

console.log(`i like ${maybe(food)}`)
//=> "i like sushi"

console.log(`${maybe(drink, 'i like ' + drink + ' too')}`)
//=> "i like tea too"

console.log(`to be ${maybe(false, 'hmmmm ')}or not to be?`)
//=> "to be or not to be?"

License

This project is licensed under the MIT License