Skip to content

mainarthur/tag-clean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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"

And without tls:

console.log(`Something ${someFalseValue && 'Optional Text'}`) // "Something false"
console.log(`Something ${someTrueValue && 'Optional Text'}`) // "Something Optional Text"
console.log(`${null}, ${undefined}, ${false}, ${''}, ${NaN}, ${0}`) // "null, undefined, false, , NaN, 0"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published