Added links to wiki for EncodeHtml, EncodeJs, EncodeJson and EncodeXml

This commit is contained in:
Erik C. Thauvin 2023-03-18 14:56:19 -07:00
parent 0f62f9cb5b
commit cea371ed31
7 changed files with 16 additions and 36 deletions

View file

@ -6,7 +6,7 @@
# [RIFE2](https://rife2.com/) Template Renderers # [RIFE2](https://rife2.com/) Template Renderers
This project provides a collection of template renderers. This project provides a collection of useful template renderers.
## Date/Time Renderers ## Date/Time Renderers
@ -24,14 +24,14 @@ This project provides a collection of template renderers.
| Renderer | Description | | Renderer | Description |
|:------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------| |:------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------|
| [rife.render.EncodeBase64](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.EncodeBase64) | Encodes a template value to Base64 | | [rife.render.EncodeBase64](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.EncodeBase64) | Encodes a template value to Base64 |
| `rife.render.EncodeHtml` | Encodes a template value to HTML | | [rife.render.EncodeHtml](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.EncodeHtml) | Encodes a template value to HTML |
| `rife.render.EncodeHtmlEntities` | Encodes a template value to HTML decimal entities | | `rife.render.EncodeHtmlEntities` | Encodes a template value to HTML decimal entities |
| `rife.render.EncodeJs` | Encodes a template value to JavaScript/ECMAScript | | [rife.render.EncodeJs](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.EncodeJs) | Encodes a template value to JavaScript/ECMAScript |
| `rife.render.EncodeJson` | Encodes a template value to JSON | | [rife.render.EncodeJson](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.EncodeJson) | Encodes a template value to JSON |
| `rife.render.EncodeQp` | Converts a template value to a quoted-printable string | | `rife.render.EncodeQp` | Converts a template value to a quoted-printable string |
| `rife.render.EncodeUnicode` | Encodes a template value to Unicode escape codes | | `rife.render.EncodeUnicode` | Encodes a template value to Unicode escape codes |
| `rife.render.EncodeUrl` | URL-encodes a template value | | `rife.render.EncodeUrl` | URL-encodes a template value |
| `rife.render.EncodeXml` | Encodes a template value to XML | | [rife.render.EncodeXml](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.EncodeXml) | Encodes a template value to XML |
## Format Renderers ## Format Renderers
@ -54,30 +54,6 @@ This project provides a collection of template renderers.
| `rife.render.Uncapitalize` | Un-capitalizes a template value | | `rife.render.Uncapitalize` | Un-capitalizes a template value |
| `rife.render.Uppercase` | Converts a template value to uppercase | | `rife.render.Uppercase` | Converts a template value to uppercase |
## Usage in Templates ## Documentation
In RIFE2, template renders are used as follows: Read more in the [full documenation](https://github.com/rife2/rife2/wiki).
```plain
<!--v render:rife.render.RendererName/-->
```
or
```plain
{{v render:rife.render.RendererName/}}
```
To specify the value ID when applicable, use:
```plain
<!--v render:rife.render.RendererName:valueId/-->
{{v render:rife.render.RendererName:valueId/}}
```
For example, to capitalize a template `foo` value:
```plain
<!--v render:rife.render.Capitalize:foo/-->
{{v render.rife.render.Capitalize:foo/}}
```

View file

@ -32,6 +32,7 @@ import rife.tools.StringUtils;
* </pre> * </pre>
* *
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a> * @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @see <a href="https://github.com/rife2/rife2-template-renderers/wiki/rife.render.EncodeHtml">rife.render.EncodeHtml</a>
* @see StringUtils#encodeHtml(String) * @see StringUtils#encodeHtml(String)
* @since 1.0 * @since 1.0
*/ */

View file

@ -32,6 +32,7 @@ import rife.tools.StringUtils;
* </pre> * </pre>
* *
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a> * @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @see <a href="https://github.com/rife2/rife2-template-renderers/wiki/rife.render.EncodeJs">rife.render.EncodeJs</a>
* @see StringUtils#encodeJson(String) * @see StringUtils#encodeJson(String)
* @since 1.0 * @since 1.0
*/ */

View file

@ -32,6 +32,7 @@ import rife.tools.StringUtils;
* </pre> * </pre>
* *
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a> * @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @see <a href="https://github.com/rife2/rife2-template-renderers/wiki/rife.render.EncodeJson">rife.render.EncodeJson</a>
* @see StringUtils#encodeJson(String) * @see StringUtils#encodeJson(String)
* @since 1.0 * @since 1.0
*/ */

View file

@ -32,6 +32,7 @@ import rife.tools.StringUtils;
* </pre> * </pre>
* *
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a> * @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @see <a href="https://github.com/rife2/rife2-template-renderers/wiki/rife.render.EncodeXml">rife.render.EncodeXml</a>
* @see StringUtils#encodeXml(String) * @see StringUtils#encodeXml(String)
* @since 1.0 * @since 1.0
*/ */

View file

@ -51,10 +51,10 @@ public final class RenderUtils {
} }
/** /**
* Encodes a string to JavaScript/ECMAScript. * Encodes a String to JavaScript/ECMAScript.
* *
* @param src the source string * @param src the source String
* @return the enocded string * @return the encoded String
*/ */
public static String encodeJS(String src) { public static String encodeJS(String src) {
if (src == null || src.isBlank()) { if (src == null || src.isBlank()) {

View file

@ -54,8 +54,8 @@ class TestEncode {
@Test @Test
void testEncodeJson() { void testEncodeJson() {
var t = TemplateFactory.JSON.get("encodeJson"); var t = TemplateFactory.JSON.get("encodeJson");
t.setAttribute(TestCase.FOO, "fde\fde\rjk\tos\\u218Foi"); t.setAttribute(TestCase.FOO, "This is a \"•test\"");
assertThat(t.getContent()).isEqualTo("{\n \"foo\": \"fde\\fde\\rjk\\tos\\\\u218Foi\"\n}"); assertThat(t.getContent()).isEqualTo("{\n \"foo\": \"This is a \\\"\\u2022test\\\"\"\n}");
} }
@Test @Test