-
Notifications
You must be signed in to change notification settings - Fork 11
Write a Template Guide
This page should instruct you with minimal words and some examples how to create a Template with Morestachio from a User perspective.
To write a Template and render it to a report you need to know about 3 parts that are involved in this process.
- The Text Template. The file that instructs the engine where to render what. The Where
- The Data Structure. The structure of data that is provided with your template. The What
- Your Formatters. The custom code that is can be used to process your data. The How
For each section you will find the more technical wiki pages at the end of each section.
All Examples include at least an example Template, corresponding Data and the expected output. The Data example with here written as Json but applies to all kinds of structured data display.
This is the part where you, the user will spend most of your time. Essentially the template defines where morestachio should write the data. You can use Morestachio to create all kinds of text based files with ease. Morestachios approach is a combination of static content and your data.
Everything you write into {{
and }}
will be considered an Expression and anything not inside double curly brackets is considered static content.
Morestachio supports several keywords and expression types that fulfills certain actions. The most simple expression is the Path expression.
Example: Path Expression - Template
{{data.Name}}
Example: Path Expression - Data
{
"data": {
"Name": "test"
}
}
Example: Path Expression - Result
test
Wiki: https://github.com/JPVenson/morestachio/wiki/Keywords
The write a Template you have to know what data you can expect when rendering this template. This data should be supplied to you by your application. Most likely it will be shown in a format called Json. You have to use the Path Expression to navigate into the depths of your data. See the https://github.com/JPVenson/morestachio/wiki/Keywords#scopeing wiki.