Appearance
Cortex Project Templates and Variables
This documentation covers how templates and variables work in Cortex projects.
Template Overview
Templates in Cortex projects are primarily markdown files (.md
) that contain variable placeholders. These templates can represent any type of document such as contracts, agreements, policies, or other text-based content.
Variable Placeholders
Variables in templates use the mustache-style double curly brace syntax:
{{variable_name}}
When the template is processed, these placeholders are replaced with actual values defined in variable files.
Example from NDA Template
The NDA template demonstrates how variables are used in practice:
markdown
This Mutual Non-Disclosure Agreement (this "**Agreement**") is entered into as of {{effective_date}} (the "**Effective Date**"), by and between:
**{{party_a}}**, a company organized under the laws of {{party_a_jurisdiction}}, having its principal place of business at {{party_a_address}} ("**{{party_a_short}}**"), and
**{{party_b}}**, a company organized under the laws of {{party_b_jurisdiction}}, having its principal place of business at {{party_b_address}} ("**{{party_b_short}}**").
This excerpt uses multiple variables:
- When the agreement takes effect
,
,
,
- Details about the first party
,
,
,
- Details about the second party
Variable Definition
Variables are typically defined in a central variables.json
file at the project level. While the NDA example doesn't include this file, it's referenced as the central place for variable definitions in a project.
A variables file might look like this:
json
{
"effective_date": "January 1, 2025",
"party_a": "ACME CORPORATION",
"party_a_jurisdiction": "Delaware, United States",
"party_a_address": "123 Main Street, Anytown, USA",
"party_a_short": "ACME",
"party_b": "TECH SOLUTIONS, INC.",
"party_b_jurisdiction": "California, United States",
"party_b_address": "456 Tech Drive, Silicon Valley, CA",
"party_b_short": "Tech Solutions",
"term_years": "3",
"survival_years": "5",
"governing_law": "the State of Delaware, United States",
"dispute_resolution": "binding arbitration in Delaware",
"party_a_signatory": "John Smith",
"party_a_title": "Chief Executive Officer",
"party_b_signatory": "Jane Doe",
"party_b_title": "President",
"signature_date": "January 1, 2025"
}
Variable Types
Variables in Cortex projects can be of various types:
- Strings: Text values like company names, addresses, or legal clauses
- Numbers: Numerical values like term lengths or monetary amounts
- Dates: For effective dates, signature dates, etc.
Variable Usage in Tests
Variables are also referenced in test files to validate their usage:
yaml
- name: Has Proper Term Length
assert: regex
pattern: "period of \\{\\{term_years\\}\\} years"
validate: "$term_years <= 5"
This test validates that:
- The template contains the pattern
period of years
- The
term_years
variable value is less than or equal to 5
Best Practices for Variables
Naming Conventions
- Use descriptive, clear names
- For related variables, use a common prefix (e.g.,
party_a_name
,party_a_address
) - Use snake_case for consistency
- Avoid abbreviations unless they're standard in the domain
Organization
- Group related variables together in the variables file
- Include comments to explain complex variables or those with specific formatting requirements
- Consider using nested structures for complex relationships
Documentation
- Document the purpose and expected format of each variable
- Indicate which variables are required versus optional
- Provide examples of valid values
Variable Resolution
When processing templates, the Cortex system:
- Reads the template file
- Identifies all variable placeholders
- Looks up each variable in the variables file
- Replaces each placeholder with its corresponding value
- Outputs the processed document with all variables resolved
Template Flexibility
Cortex templates are highly flexible:
- Templates can contain any markdown content
- Variable placeholders can appear anywhere in the template
- Templates can use conditional logic and other advanced features (depending on the implementation)
- Multiple templates can use the same variables
- Templates can be organized in any directory structure
Summary
Templates and variables are core components of Cortex projects, providing a flexible system for creating customizable documents. By separating the document structure (templates) from the specific information (variables), Cortex enables efficient creation of standardized yet customizable content.