maybe-include

0.0.3 • Public • Published

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

Package Sidebar

Install

npm i maybe-include

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

2.11 kB

Total Files

4

Last publish

Collaborators

  • zentus808