Generate Text/Html

This handler (com.rierino.handler.TemplateEventHandler) provides ability to produce text outputs using templates and input payload.

Handler Parameters

This cacheable.

Parameter
Definition
Example
Default

code.state

Name of the state manager with template definitions

template_code

handler_code

code.field

Json path for the data element of code record for template

template

code

helper

Class name for the template helper to use

com.rierino.handler.util.helper.HandlebarsTemplateHelper

-

Example Template Handler Definition (Can be Imported on Element Screen)

This handler requires the following dependency added to deployment contents:

implementation (group:'com.rierino.processors', name: 'handlebars', version:"${rierinoVersion}")

Actions

ApplyTemplate

Produces text (e.g. plain, html) from given input data and template id. Event metadata fields applicable for this action are as follows:

Field
Definition
Example
Default

inputElement

Json path for the input in request event payload

customer

-

outputElement

Json path for the output in response event payload

html

-

With event metadata parameters as:

Parameter
Definition
Example
Default

templateId

Id of the template to use from code.state

landing_page

-

templateIdPath

Json path of the template in event payload

parameters.template

-

resultPath

Json path to add produced text on output element

output

result

Example

Input

{
    "parameters": {
        "course": "Rierino 101",
        "chapters": [
            {"name": "Introduction"}
        ] 
    }
}

Event Metadata

ApplyTemplateList

Produces text from a given array of input data and template ids. Event metadata fields applicable for this action are as follows:

Field
Definition
Example
Default

inputElement

Json path for the input in request event payload

list

-

outputElement

Json path for the output in response event payload

html

-

With event metadata parameters as:

Parameter
Definition
Example
Default

structure

Structure of output to produce (, , )

map

-

delimiter

Delimiter for concatenating results if structure is "text"

\n

-

inputPath

Json path to get list of requests from

list

input

resultPath

Json path to add produced text on output element

output

result

Helpers

HandlebarsTemplateHelper

This helper (com.rierino.handler.util.helper.HandlebarsTemplateHelper) uses Handlebars library for processing given template.

Example Template
<header><h1>{{course}}</h1></header>
{{#each chapters}}
    <h2>{{name}}</h2>
    {{#each sections}}
        <h3>{{name}}</h3>
    {{/each}}
{{/each}}

FreemarkerTemplateHelper

This helper (com.rierino.handler.util.helper.FreemarkerTemplateHelper) uses Freemarker library for processing given template.

Last updated