fmt-subs

Home > fmt-subs > fmt

fmt variable

Tag function for template literals which wraps its contents into a Fmt instance.

Signature:

fmt: FmtFn

Remarks

Use sub() for values substitution

Example

// Simple usage
console.log(...fmt`Hey, ${fmt.sub('Buddy', '%s')}!`.assemble())

// Nesting fmts to each other
const part1 = fmt`Foo: ${fmt.sub({ foo: true }, '%o')}`
const part2 = fmt`Bar: ${fmt.sub({ bar: false }, '%o')}`
console.log(...fmt`Part 2: ${part2}\nPart 1: ${part1}`.assemble())