From c8a2b8bb47b29ad89bee7552757e89498b9ae803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sat, 20 Aug 2022 16:51:39 +0100 Subject: [PATCH] CustomCategory: when testing, execute templates to see if they validate --- src/customCategory.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/customCategory.js b/src/customCategory.js index 6238cb7e..8c99699c 100644 --- a/src/customCategory.js +++ b/src/customCategory.js @@ -418,8 +418,30 @@ function customCategoryTestCompile (data) { return } + let template try { - OverpassLayer.twig.twig({ data }) + template = OverpassLayer.twig.twig({ data }) + } + catch (e) { + return e + } + + const fakeOb = { + id: 'n1', + sublayer_id: 'main', + osm_id: 1, + type: 'node', + tags: { + foo: 'bar' + }, + map: { + zoom: 15, + metersPerPixel: 0.8 + } + } + + try { + template.render(fakeOb) } catch (e) { return e