tag-clean

Clears all non-true values from template string

Usage no npm install needed!

<script type="module">
  import tagClean from 'https://cdn.skypack.dev/tag-clean';
</script>

README

tag-clean

Clears all non-true values from template string

Usage example

  1. Importing

in ts:

import { tls } from 'tag-clean'

in js:

const { tls } = require('tag-clean')
  1. Using
console.log(tls`Something ${someFalseValue && 'Optional Text'}`) // "Something "
console.log(tls`Something ${someTrueValue && 'Optional Text'}`) // "Something Optional Text"
console.log(tls`${null}, ${undefined}, ${false}, ${''}, ${NaN}, ${0}`) // ", , , , , 0"