Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

type-template

Simple, type-safe string interpolation

// Import the tpl function and some default stringifiersimporttpl,{NUMBER,STRING}from'type-template';// Define a custom stringifier, a fancy name for a function mapping a value to a stringconstDATE=(value: Date)=>value.toLocaleString();// Create a templateconstmyTemplate=tpl`Something ${{num:NUMBER}} something ${{myDate:DATE}} something ${{str:STRING}}`;// myTemplate is now a function you can use for interpolationconstmyString=myTemplate({// These arguments are all type-checkednum: 96,myDate: newDate(),str: 'some other thing',});// -> 'Something 96 something 10/8/2018, 11:56:52 AM something some other thing'

About

Safe template string interpolation for TypeScript

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages