0.1.0 • Published 2 years ago

ts-template-string v0.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Template Strings

Conveniently typed string templates with a syntax heavily inpired by Template Literals:

const template = new TemplateString('Hello ${placeholder}');
template.fill({ placeholder: 'world! 🌍' }) // 'Hello world 🌍'

The template are typed using Template Literal Types and provide a nice developer experience:

const anotherTemplate = new TemplateString('A ${mandatory} ${placeholder}!');

anotherTemplate.fill({ placeholder: 'world! 🌍' }) // ❌
anotherTemplate.fill({ mandatory: 'typed', redundant: 'word' }) // ❌
anotherTemplate.fill({ andatory: 'typed' }) // ❌
anotherTemplate.fill({ mandatory: 'typed' }) // ✅