Template literal (template strings) Last updated: 13. Nov 2023

Template literals are strings that can cross multiple lines and easily bind in values through single JS expressions inside the string. The strings are started and ended with the ` symbol. Expressions are started with ${ ... } inside the string.

Parameters

This function takes no parameters

Returns

A string

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
var x = {
  "name" : "X-VALUE"
};
let result = `One line <div class="lead">${x.name}</div>
    Next line`;
    
write(result);

Output

The JS code above produces the output shown below:
One line <div class="lead">X-VALUE</div>
    Next line