String Template Format: Compose
Compose string template tags
Usage Examples
Tag that logs
// Create the tagconst log = // Use the tagconst num = 123const str = 'abc'const obj = abc: 123 def: 456 const arr = 0 1 2log`number ; string ; object ; array `
should print:
number 123; string 'abc'; object { abc: 123, def: 456 }; array [ 0, 1, 2 ]
Tag that throws
// Create the tagconst raise = { throw error }const err = // Use the tagconst obj = abc: 123 def: 456 const key = 'ghi'err`Object does not have property `
should throw:
TypeError: Object { abc: 123, def: 456 } does not have property 'ghi'