Skip to content

wintersteve/better-template-strings

Repository files navigation

better-template-strings

A lightweight template string util to make working with dynamic and nullish data a breeze.

Usage

Tired of seeing undefined in unguarded strings?

// Hello undefined!
`Hello ${data?.maybeNullish}!`;
// We have to guard for every argument
data?.maybeNullish ? `Hello ${data?.maybeNullish}!` : '';

The simple solution

import { f } from 'better-template-strings';

// Returns "" if any argument is nullish
f`Hello ${data?.maybeNullish}!`;

// Returns "Some Error Occured"
f('Some Error Occured')`Hello ${data?.maybeNullish}!`;

About

A lightweight string util to make working with dynamic and therefore possibly empty data a breeze

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published