Skip to content

Tagged template function that filters falsy values

Notifications You must be signed in to change notification settings

juliangruber/tag-truthy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tag-truthy

Tagged template function that filters falsy values.

Example

const tpl = require('tag-truthy')

const html = tpl`
  <div>
    ${condition && `
      <span>Yay!</span>
    `}
  </div>
`

If condition is truthy, this outputs as expected:

<div>
  <span>Yay!</span>
</div>

If condition is falsy, this cleans up the falsy values and outpus:

<div></div>

Without tag-truthy, the output would be:

<div>
  false
</div>

Installation

$ npm install tag-truthy

license

MIT

About

Tagged template function that filters falsy values

Resources

Stars

Watchers

Forks

Packages

No packages published