This document exists to describe a proposal for enhancing the fastn
language.
This is a Request For Comment. Please share your comments by posting them in the
pull request for this RFC if this RFC is not merged yet. If the RFC is merged,
you can post comment on our official Discord, or
open a discussion on Github.
rfc
.Jack
is stored in a variable, $name
,
currently we have to either write a function to concatenate Hello,
and $name
to form the string, or place two ftd.text
nodes, wrapped in a ftd.row
.
Neither is very nice. So we are proposing variable interpolation, which allows
easy generation of such strings with data embedded in it.$var
access in StringsAny string can now refer to any variable using the $<var-name>
syntax, so e.g.,
we can write Hello, $name
, and it will expand into Hello, Jack
is $name
is
Jack
.
$<var-name>
, we
initialise string to it.fastn
language, formula re-evalutes it's value whenever the underlying
variable changes. This means if the variable used in any string interpolation
changes, the string will automatically change as well.$ curly
syntaxThe total is $${ count * price }.
-- ftd.text: The total is ${
count * price
}
Sometimes we want to show literally Hello, $name
, in this case the author can
write Hello, $name
, escape the special handling by putting a `` in front of
$
.
$<var-name>
: $<var-name>
$<var-name>
for a
string. The behaviour described here generalises this.