Clauses
Introduction
A clause represents a dynamic part of a string that will be processed. Clauses are the backbone of ESCL, as everything happens inside a clause.
Working with clauses
You represent a clause in a string using brace brackets. This clause contains a single variable named firstName
.
You'll also notice that there is a space after the opening brace and before the closing brace. These extra padding spaces are intentionally enforced to ensure clause readability. Like the braces, they are not considered during processing.
Spaces in clauses
While the padding spaces mentioned above are not considered during processing, all other spaces are considered. This clause contains two variables with a space separating them:
Assuming we pass in the appropriate variable values for John Doe, this will output:
Notice the space between the variables is respected but the padding spaces are not.
Multiple clauses
You may also include multiple clauses in a single string:
Recursive clauses
When processing a clause, a recursive object graph is generated to represent the clause itself, the tokens it contains, and whether those tokens reference other strings which themselves contain clauses.
Using this object graph, ESCL is able to support advanced string composition functionality at depth and simplifies its usage in an application.
In this example, we build the welcome_message
string with a clause which references the user_display_name
string, and a clause with its own variable appName
:
Thanks to clause recursion, we can use welcome_message
and pass in the firstName
and lastName
variables, as though they were defined in the string itself:
Last updated