How to use "quoted string" or template literals in ReasonML?


#1

I’d like to inject values into strings when needed. In JS, I can do this:

var num = 1;
console.log(`I have ${num} car.`);

How can I do this in ReasonML without JS interop?


#2

There is a interop with {j

let num = 1;

Js.log({j|I have $num car.|j});

#3

Without JS interop, you would use Printf.sprintf library. But it’s 7KB gzipped when compiling to JS