Expression Equality Bracket

Overview


The expression equality brackets are given by {= =}. When found inside the body of a dynamic text document, the expression between the brackets is evaulated and then the brackets are replaced by the value of the expression.

A First Example


The simplest way to understand the exression equality bracket is to see it used in an example. The following shows placing an expression (in this case, 2+3) inside the brackets.

The sum and 2 and 3 is {= 2+3 =}
					
Try it!
The generated output in your document will be

The sum and 2 and 3 is 5
					
Expressions are demarcated with the curly brace and equal sign, which essentially means the text here should equal the value of evaluating the expression within. If the expression resolves to undefined, nothing is displayed. If it resolves to a promise, then the result will be the result of the promise. (see asynchronous programming)

Binding to Data


One of the typical uses of dynamic text is to use outside data to populate the text. For example, suppose that the prices of a given equity has been imported into your workspace. (data consists of objects such as {date:'2020-01-01', price:100}). One may wish to quote the maximum price that was attained in the given period.

The maximum price is {= $list($val('prices')).map(p=>p.price).max() =}
					
The expression does several things. First it retrieves the named dataset "prices" from $val. Next it wraps it with a $list object. Using the query mechanism of the $list api, the prices are extracted from the list of objects, and then the maximum value is calculated.

Linking Files


One way to create automation is to have a template of boilerplate text that you want to link into your document. For example, the boilerplate text that is hosted in the davinci latex library.

To link in a text file that is hosted at a given URL, you can use the $url function, which retrieves the text.

{= $url('http://www.server.com/boilerplate.txt') =}
					
For more information about linking and rendering boilerplate templates, see:

boilerplate

Contents