From 6b291b5f9772eacda81adc01d218bec9c68f3258 Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Sun, 2 Dec 2018 20:32:29 +0800 Subject: [PATCH] feat: allow to use custom data for template interpolation --- lib/runActions.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/runActions.js b/lib/runActions.js index 7c8132c..609e843 100644 --- a/lib/runActions.js +++ b/lib/runActions.js @@ -68,9 +68,16 @@ module.exports = async (config, context) => { transformer.render( contents, config.transformerOptions, - Object.assign({}, context.answers, { - context - }) + Object.assign( + {}, + context.answers, + typeof config.templateData === 'function' + ? config.templateData.call(context, context) + : config.templateData, + { + context + } + ) ).body ) })