|
|
@@ -3,11 +3,7 @@
|
|
|
* @name Template
|
|
|
* @category data
|
|
|
* @version 1.0.0
|
|
|
- * @description Render text from a template. In "config" mode the {{...}} placeholders in the
|
|
|
- * template are already resolved by the engine before this node runs, so rendering only catches
|
|
|
- * whatever the engine could not fill in. In "input" mode the template text is read from the
|
|
|
- * input data at run time, where its {{...}} placeholders are still intact, and this node
|
|
|
- * renders them against the input.
|
|
|
+ * @description Render text from a template, either typed into the config or read from the input data at run time
|
|
|
* @icon file-text
|
|
|
*/
|
|
|
|
|
|
@@ -38,7 +34,8 @@ const configSchema = {
|
|
|
title: 'Output Field',
|
|
|
default: 'text'
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ required: ['template']
|
|
|
};
|
|
|
|
|
|
const inputSchema = {
|
|
|
@@ -62,6 +59,9 @@ async function execute(config, input, context) {
|
|
|
let template;
|
|
|
if (templateSource === 'input') {
|
|
|
const templateField = config.templateField;
|
|
|
+ if (!templateField) {
|
|
|
+ throw new Error('Template: Template Field must be set when the template comes from the input');
|
|
|
+ }
|
|
|
template = smartbotic.utils.getFieldValue(input, templateField);
|
|
|
if (typeof template !== 'string' || template === '') {
|
|
|
throw new Error('Template: no template text found at "' + templateField + '"');
|