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
This function takes a template `template` and a parsed JSON structure `data`. It returns true on success or false on failure. On success, `document.string` is set to the result, if not `errorMessage.string` is filled with an error message.
26
-
27
-
To parse a JSON string into an `Element` structure, use:
30
+
This function takes a template string `template` and JSON string `json`. It returns true on success or false on failure. On success, `document.string` is set to the result; on failure `errorMessage.string` is filled with an error message.
28
31
29
-
```
30
-
public static boolean ReadJSON(char [] string, ElementReference elementReference, StringArrayReference errorMessages)
31
-
```
32
32
33
-
Here, `string` is the JSON string. The function returns true on success and false on failure. If success, `elementReference.element` is set to the the result, if not `errorMessages.stringArray` is filled with error messages.
34
-
35
-
## General User Guide
33
+
## General About Templates
36
34
A textual template is text with certain parts left out that will be filled in by a generation step. The source for filling in is a data structure generated from a JSON file.
37
35
38
36
Templates are used for many different things in production systems. Most websites are generated based on a template, be it directly in the front end, such as with Angular, React and Vue, or in the backend. Templates are also used for production of formal documents and emails.
39
37
40
-
### Tags and Their Functions
41
38
42
-
#### Print Value
39
+
## Tags and Their Functions
40
+
41
+
### Print Value
43
42
```
44
43
{print a}
45
44
```
46
45
47
46
Will print the value of a. If it is a JSON object or structure, the JSON repressentation will be printed.
48
47
49
-
####Use structure
48
+
### Use structure
50
49
```
51
50
{use a}
52
51
{print b}
@@ -55,15 +54,15 @@ Will print the value of a. If it is a JSON object or structure, the JSON repress
55
54
56
55
This will cause a.b to be printed. Inside the use structure, the variables inside structure a can be used.
57
56
58
-
####Iterate
57
+
### Iterate
59
58
```
60
59
{foreach a in b}
61
60
{end}
62
61
```
63
62
64
63
This will iterate over all elements of the array `b`. Each element will be known as `a` inside. If `a` is an object, it will automatically be used inside the foreach loop, so there is no need to write `{use a}`.
65
64
66
-
####If-else
65
+
### If-else
67
66
```
68
67
{if a}
69
68
{else}
@@ -75,16 +74,18 @@ If a is true, the first block is printed, else the else block. The else block is
75
74
### Escape
76
75
If you want to output `{` followed directly by one of the command strings, use a backslash in front. If the `{` is not followed directly by one of the commands, the text is simply output.
77
76
78
-
### How to Work with Templates
77
+
78
+
79
+
## How to Work with Templates
79
80
There are three main issues with using templates:
80
81
81
-
####The data model
82
+
### The data model
82
83
Generate all the data that is to be filled into the document. This includes decision variables if some information is included or left out based on conditions.
83
84
84
-
####Templates
85
+
### Templates
85
86
Write the template with the tags to fill in information. There is no need for complex logic or formatting commands, as this should be taken care of during data model generation. The reason is that the code should be in the code and not in the template.
86
87
87
-
####Locale and Formatting
88
+
### Locale and Formatting
88
89
Special formatting of numbers should be taken care of during data model generation. This is better as a full fledged programming language is available.
0 commit comments