Skip to main content

String Interpolation

Symbol: `
Translated to JavaScript template strings
It takes 1+ parameters.
Each parameter is a string with ${n} symbols where n is an integer and substitution parameters.
Substitution parameter can be either value or function.


= name 'John'
= count 5
= fruit 'apples'
= text `
'Hello, ${0}' name
'I have ${0} ${1}'
console.log text

This code will print:

Hello, John
I have 5 apples

You can also pass the special interpolation function as the first parameter. E.g., usage of styled.div from styled-components:

= Container `
'background-color: ${0};'
-> ((: theme))