|
| 1 | +# Module 1: Introduction to TemplateMark |
| 2 | + |
| 3 | +The **TemplateMark** language is a crucial element of the Accord Project template system. It allows you to craft templates using a mix of _natural language text_ and _markup syntax_, making it possible to create documents that are both _human-readable_ and _machine-readable_. In this module, we will delve into the basics of TemplateMark, showcasing its key features and demonstrating its practical application within the Accord Project Template Playground. |
| 4 | + |
| 5 | +## What is TemplateMark? |
| 6 | + |
| 7 | +TemplateMark is a markup language used for defining templates in the Accord Project. It combines plain text with specific notations, enabling templates to be interpreted and processed by computers while remaining understandable to humans. |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +Templates in Accord Project are made up of three essential elements: |
| 12 | + |
| 13 | +- **Template Text**: The natural language content of the template. |
| 14 | +- **Template Model**: The data model that provides the connection between the text and the executable logic. |
| 15 | +- **Template Logic**: The business rules and logic that define how the template is processed and used. |
| 16 | + |
| 17 | +These components work together to create a powerful tool for contract automation and management. |
| 18 | + |
| 19 | +## Example of Template Text |
| 20 | + |
| 21 | +Let's explore a TemplateMark example for a **Service Agreement** clause: |
| 22 | + |
| 23 | +```js |
| 24 | +## Service Agreement |
| 25 | + |
| 26 | +{{provider}} agrees to provide the following services to {{client}}: |
| 27 | + |
| 28 | +- **Service 1**: {{service1Description}} |
| 29 | +- **Service 2**: {{service2Description}} |
| 30 | + |
| 31 | +The services will be delivered according to the following schedule: |
| 32 | + |
| 33 | +- **Start Date**: {{startDate as "D MMMM YYYY"}} |
| 34 | +- **End Date**: {{endDate as "D MMMM YYYY"}} |
| 35 | + |
| 36 | +Payment terms are as follows: |
| 37 | + |
| 38 | +- **Amount**: {{paymentAmount as "0,0.00 USD"}} |
| 39 | +- **Due Date**: {{paymentDueDate as "D MMMM YYYY"}} |
| 40 | + |
| 41 | +Any changes to the service agreement must be documented in writing and agreed upon by both parties. |
| 42 | +``` |
| 43 | + |
| 44 | +In this template: |
| 45 | + |
| 46 | +- `{{provider}}`, `{{client}}`, `{{service1Description}}`, `{{service2Description}}`, `{{startDate}}`, `{{endDate}}`, `{{paymentAmount}}`, and `{{paymentDueDate}}` are placeholders that will be replaced with actual values when the template is used. |
| 47 | + |
| 48 | +Here's how the same clause looks with placeholder values filled in: |
| 49 | + |
| 50 | +```md |
| 51 | +## Service Agreement |
| 52 | + |
| 53 | +"ABC Services Ltd." agrees to provide the following services to "XYZ Corp": |
| 54 | + |
| 55 | +- **Service 1**: Monthly IT support and maintenance |
| 56 | +- **Service 2**: On-site technical assistance |
| 57 | + |
| 58 | +The services will be delivered according to the following schedule: |
| 59 | + |
| 60 | +- **Start Date**: 1 September 2024 |
| 61 | +- **End Date**: 31 August 2025 |
| 62 | + |
| 63 | +Payment terms are as follows: |
| 64 | + |
| 65 | +- **Amount**: $5,000.00 |
| 66 | +- **Due Date**: 1 September 2024 |
| 67 | + |
| 68 | +Any changes to the service agreement must be documented in writing and agreed upon by both parties. |
| 69 | +``` |
| 70 | + |
| 71 | +## Key Features of TemplateMark |
| 72 | + |
| 73 | +- **Variables**: Use `{{` and `}}` to denote placeholders in your template. These placeholders are replaced with specific values during template processing. |
| 74 | +- **Conditional Sections**: Incorporate or exclude sections based on conditions using `{{#clause}} ... {{/clause}}`. |
| 75 | +- **Formatting**: Apply formatting like bold or italics to emphasize important terms. |
| 76 | +- **Lists**: Organize information using ordered or unordered lists. |
| 77 | + |
| 78 | +## Practical Example in the Playground |
| 79 | + |
| 80 | +In the Template Playground, you can interact with TemplateMark templates such as: |
| 81 | + |
| 82 | +```js |
| 83 | +### Welcome {{username}}! |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | +{{#clause personalDetails}} |
| 88 | +#### Personal Details |
| 89 | +> {{firstName}} {{lastName}}, |
| 90 | + {{address}}, {{city}}, {{state}}, |
| 91 | + {{country}} |
| 92 | + {{/clause}} |
| 93 | + |
| 94 | +- Your date of birth is *{{dob as "D MMMM YYYY"}}* |
| 95 | +- Your annual salary is {{annualSalary as "0,0.00 USD"}} |
| 96 | +- Your preferred contact method is {{contactMethod}} |
| 97 | + |
| 98 | +{{#clause recentActivity}} |
| 99 | +## Recent Activity |
| 100 | +You signed up on {{signupDate as "D MMMM YYYY"}} ({{% return now.diff(user.signupDate, 'day')%}} days ago). |
| 101 | + |
| 102 | +{{#ulist recentPurchases}} |
| 103 | +- {{quantity}}x _{{item}}_ @ ${{price as "0,0.00"}} |
| 104 | +{{/ulist}} |
| 105 | +Total spent: {{% return '£' + user.recentPurchases.map(purchase => purchase.price * purchase.quantity).reduce((sum, cur) => sum + cur).toFixed(2);%}} |
| 106 | +{{/clause}} |
| 107 | + |
| 108 | +Thank you for being with us! |
| 109 | +``` |
| 110 | +
|
| 111 | +In this example: |
| 112 | +
|
| 113 | +- **Welcome Message**: Personalize messages with dynamic values. |
| 114 | +- **Personal Details Clause**: Display personal information conditionally. |
| 115 | +- **Recent Activity**: List recent purchases with calculations. |
| 116 | +
|
| 117 | +## Summary |
| 118 | +
|
| 119 | +In this module, we introduced TemplateMark, highlighting its role in creating flexible and dynamic templates. By understanding TemplateMark, you can build templates that combine natural language with computer logic, enabling sophisticated document automation and management. |
| 120 | +
|
| 121 | +## What's Next? |
| 122 | +
|
| 123 | +In the next module, we'll explore the **Template Model**—the data structure that supports and enhances the TemplateMark text. We'll cover how the Template Model integrates with TemplateMark to enable dynamic and functional templates. Stay tuned for a deep dive into the data modeling aspect of Accord Project templates! |
0 commit comments