bug: should check the children of the first parse, not the root.

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2021-11-24 13:55:28 +01:00
parent a7d3cbf79c
commit 92405f32bb
2 changed files with 3 additions and 2 deletions
@@ -114,9 +114,10 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
private isSingleTemplateString(input: string) {
const { parser, nodes } = require('nunjucks');
const parsed = parser.parse(input, {}, this.nunjucksOptions);
return (
parsed.children.length === 1 &&
!(parsed.children[0] instanceof nodes.TemplateData)
!(parsed.children[0]?.children?.[0] instanceof nodes.TemplateData)
);
}
@@ -147,7 +148,7 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
return JSON.parse(templated);
}
} catch (ex) {
this.options.logger.error(
console.error(
`Failed to parse template string: ${value} with error ${ex.message}`,
);
}