You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/markup-templatemark.md
-96
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
722
722
follows: "bank transfer".
723
723
724
724
```
725
-
726
-
## Ergo Formulas
727
-
728
-
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).
729
-
730
-
::: note
731
-
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.
732
-
:::
733
-
734
-
### Evaluation Context
735
-
736
-
The context in which expressions within templates text are evaluated includes:
737
-
- The contract variables, which can be accessed using the variable name (or `contract.variableName`)
738
-
- All constants or functions declared or imported in the main [Ergo module](logic-module) for your template.
739
-
740
-
#### Fixed Interests Clause
741
-
742
-
For instance, let us look one more time at [fixed rate loan](https://templates.accordproject.org/[email protected]) clause that was used previously:
743
-
744
-
```tem
745
-
## Fixed rate loan
746
-
747
-
This is a *fixed interest* loan to the amount of {{loanAmount}}
748
-
at the yearly interest rate of {{rate}}%
749
-
with a loan term of {{loanDuration}},
750
-
and monthly payments of {{% monthlyPaymentFormula(loanAmount,rate,loanDuration) %}}
751
-
```
752
-
753
-
The [`logic` directory](https://github.com/accordproject/cicero-template-library/tree/master/src/fixed-interests/logic) for that template includes two Ergo modules:
754
-
```
755
-
./logic/interests.ergo // Module containing the monthlyPaymentFormula function
756
-
./logic/logic.ergo // Main module
757
-
```
758
-
759
-
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:
760
-
```
761
-
namespace org.accordproject.interests
762
-
763
-
import org.accordproject.loan.interests.*
764
-
765
-
contract Interests over TemplateModel {
766
-
...
767
-
}
768
-
```
769
-
770
-
### Examples
771
-
772
-
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.
773
-
774
-
#### Path expressions
775
-
776
-
The contents of complex values can be accessed using the `.` notation.
777
-
778
-
For instance the following template uses the `.` notation to access the first name and last name of the contract author.
779
-
780
-
```tem
781
-
This contract was drafted by {{% author.name.firstName %}} {{% author.name.lastName %}}
782
-
```
783
-
784
-
#### Built-in Functions
785
-
786
-
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.
787
-
788
-
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:
789
-
790
-
```tem
791
-
This lease was signed on {{signatureDate}}, and is valid for a {{leaseTerm}} period.
792
-
This lease will expire on {{% addPeriod(signatureDate, leaseTerm) %}}`
793
-
```
794
-
795
-
#### Iterators
796
-
797
-
Ergo's `foreach` expressions lets you iterate over collections of values.
798
-
799
-
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:
800
-
801
-
```tem
802
-
The average price of the products included in this purchase
803
-
order is {{% avg(foreach p in products return p.price) %}}.
804
-
```
805
-
806
-
#### Conditionals
807
-
808
-
Conditional expressions lets you include alternative text based on arbitrary conditions.
809
-
810
-
For instance, the following template uses a conditional expression to indicate the governing jurisdiction:
811
-
812
-
```tem
813
-
Each party hereby irrevocably agrees that process may be served on it in
0 commit comments