-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(development): removed reference to ERGO in docs markup-templatema…
…rk, as it's outdated (#430) Signed-off-by: Vinyl-Davyl <[email protected]>
- Loading branch information
1 parent
5424e89
commit 5d2ad7e
Showing
1 changed file
with
0 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -722,99 +722,3 @@ fee in the amount of "one hundred US Dollars" (100.0 USD) upon execution of this | |
follows: "bank transfer". | ||
|
||
``` | ||
|
||
## Ergo Formulas | ||
|
||
Ergo formulas in template text are essentially similar to Excel formulas, and enable to create legal text dynamically, based on the other variables in your contract. They are written `{{% ergoExpression %}}` where `ergoExpression` is any valid [Ergo Expression](logic-ergo). | ||
|
||
::: note | ||
Formulas allow the template developer to generate arbitrary contract text from other contract and clause variables. They therefore cannot be used to set a template model variable during parsing. In other words formulas are evaluated when drafting a contract but are ignored when parsing the contract text. | ||
::: | ||
|
||
### Evaluation Context | ||
|
||
The context in which expressions within templates text are evaluated includes: | ||
- The contract variables, which can be accessed using the variable name (or `contract.variableName`) | ||
- All constants or functions declared or imported in the main [Ergo module](logic-module) for your template. | ||
|
||
#### Fixed Interests Clause | ||
|
||
For instance, let us look one more time at [fixed rate loan](https://templates.accordproject.org/[email protected]) clause that was used previously: | ||
|
||
```tem | ||
## Fixed rate loan | ||
This is a *fixed interest* loan to the amount of {{loanAmount}} | ||
at the yearly interest rate of {{rate}}% | ||
with a loan term of {{loanDuration}}, | ||
and monthly payments of {{% monthlyPaymentFormula(loanAmount,rate,loanDuration) %}} | ||
``` | ||
|
||
The [`logic` directory](https://github.com/accordproject/cicero-template-library/tree/master/src/fixed-interests/logic) for that template includes two Ergo modules: | ||
``` | ||
./logic/interests.ergo // Module containing the monthlyPaymentFormula function | ||
./logic/logic.ergo // Main module | ||
``` | ||
|
||
A look inside the `logic.ergo` module shows the corresponding import, which ensures the `monthlyPaymentFormula` function is also in scope in the text for the template: | ||
``` | ||
namespace org.accordproject.interests | ||
import org.accordproject.loan.interests.* | ||
contract Interests over TemplateModel { | ||
... | ||
} | ||
``` | ||
|
||
### Examples | ||
|
||
Ergo provides a wide range of capabilities which you can use to construct the text that should be included in the final clause or contract. Below are a few examples for illustrations, but we encourage you to consult the [Ergo Logic](logic-ergo) guide for a more comprehensive overview of Ergo. | ||
|
||
#### Path expressions | ||
|
||
The contents of complex values can be accessed using the `.` notation. | ||
|
||
For instance the following template uses the `.` notation to access the first name and last name of the contract author. | ||
|
||
```tem | ||
This contract was drafted by {{% author.name.firstName %}} {{% author.name.lastName %}} | ||
``` | ||
|
||
#### Built-in Functions | ||
|
||
Ergo offers a number of pre-defined functions for a variety of primitive types. Please consult the [Ergo Standard Library](ref-logic-stdlib) reference for the complete list of built-in functions. | ||
|
||
For instance the following template uses the `addPeriod` function to automatically include the date at which a lease expires in the text of the contract: | ||
|
||
```tem | ||
This lease was signed on {{signatureDate}}, and is valid for a {{leaseTerm}} period. | ||
This lease will expire on {{% addPeriod(signatureDate, leaseTerm) %}}` | ||
``` | ||
|
||
#### Iterators | ||
|
||
Ergo's `foreach` expressions lets you iterate over collections of values. | ||
|
||
For instance the following template uses a `foreach` expression combined with the `avg` built-in function to include the average product price in the text of the contract: | ||
|
||
```tem | ||
The average price of the products included in this purchase | ||
order is {{% avg(foreach p in products return p.price) %}}. | ||
``` | ||
|
||
#### Conditionals | ||
|
||
Conditional expressions lets you include alternative text based on arbitrary conditions. | ||
|
||
For instance, the following template uses a conditional expression to indicate the governing jurisdiction: | ||
|
||
```tem | ||
Each party hereby irrevocably agrees that process may be served on it in | ||
any manner authorized by the Laws of {{% | ||
if address.country = US and getYear(now()) > 1959 | ||
then "the State of " ++ address.state | ||
else "the Country of " ++ address.country | ||
%}} | ||
``` | ||
|