From 3fc8f9ff5b242369312ac14d866b708c757cafd4 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Fri, 2 Jul 2021 12:19:17 +0200 Subject: [PATCH] scaffolder: add some explanations and todos on nunjucks action Co-authored-by: Mike Lewis Signed-off-by: Himanshu Mishra --- .../src/scaffolder/actions/builtin/fetch/template.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts index 93a158ca37..5a12191010 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts @@ -108,14 +108,19 @@ export function createFetchTemplateAction(options: { // Create a templater const templater = nunjucks.configure({ + // TODO(mtlewis/orkohunter): Document Why we are changing the literals? Not here, but on scaffolder docs. ADR? tags: { variableStart: '${{', variableEnd: '}}', }, + // We don't want this builtin auto-escaping since it is escaping as HTML which will often be incorrect e.g. adds things like " autoescape: false, }); - // TODO(mtlewis/orkohunter) Need to work out how to autoescape but not this + // TODO(mtlewis/orkohunter) Evaluate whether this behavior is still appropriate when using nunjucks. + // As of now jsonify seems to be the most reliable way to do escaping, + // but is there a builtin filter to do this inside nunjucks + // (other than `autoescape` inside `configure` which escapes strings as HTML, which isn't right.). templater.addFilter('jsonify', s => JSON.stringify(s)); for (const location of allFilesInTemplates) { @@ -131,8 +136,6 @@ export function createFetchTemplateAction(options: { ), ); } - - // TODO(mtlewis/orkohunter) log success }, }); }