Strings & Text

SEL can handle word-like things too! We call these strings and text.

Strings are short, single-line bits of text and there is an event type dedicated to defining a string, the eponymous:

String

You can declare a String in SEL by writing:

=String("Hollow World ...")

A string event will report its value in the ledger as the length of its contents. In the above example, this would be 16.

Certain event types know how to handle strings.

Matches (Regular Expressions)

Perhaps you'd like to see if a string contains a certain expression, but you don't know for sure what the substring will look like. To do that, SEL provides the Matches event. The only argument to the Matches event type is a regular expression, or regex for short.

We can use this event type like so:

=Matches("\d")

This will check to see if a String contains a digit.

Matches returns the matches it finds as a list, which can then be used by other downstream events. Matches will report the number of matches in the ledger.

In addition to searching for matches inside String events, the Matches event will also search for matches inside lists of strings, such as those returned by the Parser event.

πŸ““

The World of Regular Expressions

Summit uses the Python re module to perform regular expression matches.

Regexes are endlessly powerful and complex! Learning them is far beyond the scope of this documentation, but if you can learn the spells of regex, you will be a powerful SEL wizard indeed.

Text

Eventually we may want to handle large swaths of words that can span multiple lines. The event type for handling this kind of data in SEL is called Text. We can declare it like so:

=Text("""Call me Ishmael ... """)

The Text event should always start and end with triple quotes: """".

One special power of the Text type is its ability to incorporate liquid syntax, which contains a veritable ocean of ways to filter, transform, and format text, for example:

=Text(""" {{ "moby dick" | capitalize }} """)

Would generate the value: MOBY DICK.

Most powerfully, you can refer to the value of other events on the canvas by using their titles. If you had a String event like so:

=String('whale of a tale')

And its title was draft_book_name, then you could use that string in your Text block:

=Text(""" I am thinking of writing a book. Its title is {{ draft_book_name | capitalize }}, but this is just a working title. I'm hoping to think of something better. """)

Then this will insert WHALE OF A TALE into the sentence.

Events that return arrays, lists, or objects will also be treated as such inside of your Text block.

🚧

Variable Naming Rules

Since liquid syntax forbids the use of spaces, special characters, or starting with numbers for variable names, any events you wish you use inside a liquid syntax portion of a Text event must conform to this standard. We recommend using lowercase_event_titles_with_underscores_for_spaces in this case.

Using Text inside Text

You may also wish to insert or use the rendered contents of a Text event inside a separate Text event.

This is perfectly fine; simply use the title to refer to it like any other event:

=Text(""" This text event uses the contents of another text event. You can read it here: {{ my_other_text_event }}.""")

However, you must make sure that the event you wish to insert (ex. my_other_text_event) is evaluated first. You can do this (and avoid what's known as a "race condition") by using a route to draw an arrow from the first text event to the second. This ensures that the second text event will not render until after the first has finished.