What you’ll build
You’ll create a JSON data object that matches the structure defined in yourHelloWorld model and watch as it dynamically populates your template.
Creating template data
Follow these steps to generate data for your template:Understand the data structure
Your data must conform to the shape defined by your Concerto model. Every data object needs:
- A
$classproperty that identifies the concept type - Properties that match the model definition
Define the data object
Create an instance of the This object:
[email protected] data model:- Uses
$classto specify it’s an instance of[email protected] - Sets the
nameproperty to"World"
Understanding the $class property
The$class property is crucial for data binding:
- It must match the fully qualified name of your concept:
[email protected] - For the HelloWorld example:
[email protected] - This allows the template engine to validate data against the correct model
Complete example
Here’s how all three pieces work together: Model (from Module 1):Working with complex data
As your templates become more sophisticated, your data objects will include more properties and different data types.Multiple properties
Model:Date values
Notice how dates are provided in ISO 8601 format ("2024-10-01T00:00:00Z"). The template can then format this date for display using the as keyword:
Data validation
The Accord Project template engine validates your data against the Concerto model:Valid data: All required properties are present and have correct types
Testing different data
You can experiment with different data values to see how they populate your template:Programmatic data generation
In a real application, you might generate data programmatically:Next steps
Congratulations! You’ve completed the learning pathway and created your first Accord Project template. You now understand:- How to define data models with Concerto
- How to create dynamic templates with TemplateMark
- How to bind JSON data to templates
Continue learning
Explore sample templates
See more complex examples and real-world use cases
Concerto documentation
Deep dive into advanced Concerto features
TemplateMark guide
Learn advanced templating techniques
API reference
Integrate templates into your applications
Key concepts
What is the $class property?
What is the $class property?
The
$class property identifies the type of data object. It must be the fully qualified name of a concept from your Concerto model ([email protected]). The template engine uses this to validate the data structure.How is data validated?
How is data validated?
The Accord Project template engine validates your data against the Concerto model to ensure all required properties are present and have the correct types. This prevents runtime errors and ensures data consistency.
Can I use nested objects?
Can I use nested objects?
Yes! Concerto supports complex data structures including nested concepts, arrays, and relationships. Your JSON data can include nested objects that match your model’s structure.
How do I handle optional properties?
How do I handle optional properties?
Properties marked as optional in your Concerto model (using
o prefix) don’t need to be included in your data object. The template should handle missing values gracefully.