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
Copy file name to clipboardExpand all lines: README.md
+7-10Lines changed: 7 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,6 @@ HTTP-RPC is an open-source framework for implementing RESTful and REST-like web
6
6
7
7
This guide introduces the HTTP-RPC framework and provides an overview of its key features.
8
8
9
-
# Feedback
10
-
Feedback is welcome and encouraged. Please feel free to [contact me](mailto:gk_brown@icloud.com?subject=HTTP-RPC) with any questions, comments, or suggestions. Also, if you like using HTTP-RPC, please consider [starring](https://github.com/gk-brown/HTTP-RPC/stargazers) it!
11
-
12
9
# Contents
13
10
*[Getting HTTP-RPC](#getting-http-rpc)
14
11
*[HTTP-RPC Classes](#http-rpc-classes)
@@ -560,7 +557,7 @@ would produce the following output:
560
557
Enums are encoded using their ordinal values. Instances of `java.util.Date` are encoded as a long value representing epoch time. All other values are encoded via `toString()`. Unsupported (i.e. non-map) sequence elements are ignored.
561
558
562
559
## TemplateEncoder
563
-
The `TemplateEncoder` class is responsible for merging a [template document](template-reference.md) with a data dictionary. It provides the following constructors:
560
+
The `TemplateEncoder` class transforms an object hierarchy into an output format using a [template document](template-reference.md). It provides the following constructors:
The first argument represents the value to write (i.e. the data dictionary), and the second the output destination. The optional third argument represents the locale for which the template will be applied. If unspecified, the default locale is used.
@@ -606,7 +603,7 @@ TemplateEncoder encoder = new TemplateEncoder(getClass().getResource("map.txt"),
606
603
607
604
String result;
608
605
try (StringWriter writer =newStringWriter()) {
609
-
encoder.writeValue(map, writer);
606
+
encoder.write(map, writer);
610
607
611
608
result = writer.toString();
612
609
}
@@ -633,7 +630,7 @@ Modifiers are created by implementing the `TemplateEncoder.Modifier` interface,
The first argument to this method represents the value to be modified, and the second is the optional argument value following the `=` character in the modifier string. If an argument is not specified, this value will be `null`. The third argument contains the encoder's locale.
633
+
The first argument to this method represents the value to be modified, and the second is the optional argument value following the "=" character in the modifier string. If an argument is not specified, this value will be `null`. The third argument contains the encoder's locale.
637
634
638
635
For example, the following code creates a modifier that converts values to uppercase:
Copy file name to clipboardExpand all lines: template-reference.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,9 +23,9 @@ Variable names represent keys into the data dictionary. When the template is pro
23
23
24
24
Nested values can be referred to using path notation; e.g. "name.first". Missing (i.e. `null`) values are replaced with the empty string in the generated output.
25
25
26
-
Variable names beginning with "@" represent resource references, and are replaced with the corresponding values from the provided resource bundle when the template is processed.
26
+
Variable names beginning with "@" represent resource references, and are replaced with the corresponding values from the resource bundle when the template is processed.
27
27
28
-
Variable names beginning with "$" represent context references, and are replaced with the corresponding values from the provided context dictionary when the template is processed.
28
+
Variable names beginning with "$" represent context references, and are replaced with the corresponding values from the template context when the template is processed.
29
29
30
30
### Modifiers
31
31
Modifiers are used to transform a variable's representation before it is written to the output stream; for example, to apply an escape sequence.
@@ -39,7 +39,7 @@ Modifiers are specified as shown below. They are invoked in order from left to r
39
39
All templates support the following set of standard modifiers:
40
40
41
41
*`format` - applies a [format string](https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html#syntax)
42
-
*`^html`, `^xml`- applies markup encoding to a value
42
+
*`^html`- applies HTML encoding to a value
43
43
*`^url` - applies URL encoding to a value
44
44
45
45
For example, the following marker applies a format string to a value and then URL-encodes the result:
@@ -122,7 +122,7 @@ For example, a data dictionary that contains information about homes for sale mi
122
122
}
123
123
```
124
124
125
-
A template to present these results in an HTML table is shown below. The section markers are enclosed in HTML comments so they will be ignored by syntax-aware text editors, and will simply resolve to empty comment blocks when the template is processed:
125
+
A template to transform these results into HTML is shown below. The section markers are enclosed in HTML comments so they will be ignored by syntax-aware text editors, and will simply resolve to empty comment blocks when the template is processed:
126
126
127
127
```html
128
128
<table>
@@ -137,7 +137,9 @@ A template to present these results in an HTML table is shown below. The section
137
137
</table>
138
138
```
139
139
140
-
A dot character (".") can be used to represent the current element in a sequence. This can be useful when rendering scalar values. A dot can also be used to represent the sequence itself; for example, when a sequence is the root object:
140
+
A dot character (".") can be used to represent the current element in a sequence. This can be useful when rendering scalar values.
141
+
142
+
A dot can also be used to represent the sequence itself; for example, when a sequence is the root object:
141
143
142
144
```
143
145
{{#.}}
@@ -174,7 +176,9 @@ Hello, World!
174
176
Includes inherit their context from the parent document, so they can refer to elements in the parent's data dictionary. This allows includes to be parameterized. Self-referencing includes can also be used to facilitate recursion.
175
177
176
178
## Comments
177
-
Comment markers provide informational text about a template's content. They are not included in the final output. For example, when the following template is processed, only the content between the `<p>` tags will be included:
179
+
Comment markers provide informational text about a template's content. They are not included in the final output.
180
+
181
+
For example, when the following template is processed, only the content between the `<p>` tags will be included:
0 commit comments