-
Notifications
You must be signed in to change notification settings - Fork 0
Variable Interpolation in Text
LegaleseScript allows for the inclusion of variables directly within the text of a contract through a process called variable interpolation. This feature enables the dynamic insertion of variable values into the contract text, making the template more flexible and easier to read.
To interpolate a variable into the text, use the curly braces {} syntax with the variable name inside.
Text contractIntroduction = "This Agreement is made between {employer} and {employee} on {effectiveDate}.";When the contract is processed, {employer}, {employee}, and {effectiveDate} will be replaced with their respective variable values.
Before you can interpolate variables, they must be defined in the scope of the contract.
section EmploymentAgreement {
Party employer = "Acme Corporation";
Party employee = "John Doe";
Date effectiveDate = Date("2023-01-01");
Text contractIntroduction = "This Agreement is made between {employer} and {employee} on {effectiveDate}.";
// Logic and obligations go here
}In this example, the contractIntroduction text will render as "This Agreement is made between Acme Corporation and John Doe on 01 January 2023." once processed.
During the rendering or compilation process, LegaleseScript will dynamically replace the placeholders with actual variable values.
// When the contract is compiled or rendered, the placeholders are replaced:
render(contractIntroduction);
// Output: This Agreement is made between Acme Corporation and John Doe on 01 January 2023.Variable interpolation is a powerful feature of LegaleseScript that simplifies the creation of dynamic and reusable contract templates. By embedding variables directly within the contract text, authors can create contracts that are both flexible and maintain the formal structure required for legal documents.