Expressions

Expressions are strings or HTML markup whose contents can be replaced with the values of an object when evaluated.

String

Use variables enclosed in brackets { } in string expressions to represent the properties of an object. The properties will be replaced with the values of the properties within the object when evaluated.

Use the string function extension eval to evaluate an expression using an object passed into the function.

const data = {company: "Acme", employee: "Fred" };

const str = "{employee} works for {company}".eval(data);

// Fred works at Acme

HTML

These same expressions can be set up inside HTML markup and evaluated using the wire.ui.eval method.

The first parameter to this method is the selector for the DOM element container for the markup. The second is the data to be used to evaluate expressions in the markup.

Consider the markup below.

<div id="exp">
    <span>{employee} works for</span><span>{company}</span>
</div>

Use the wire.ui.eval method to evaluate the containing element exp using the data object from the previous example.

wire.ui.eval("#exp", data);

Last updated