add initContext helper to set fields we expect to be present
[squeep-html-template-helper] / lib / template-helper.js
index c983e80acd44329fc6c516ee874198fc2d2e6e58..2a218f88020c3542a5bc24dffe849293f748c76b 100644 (file)
@@ -6,6 +6,17 @@
 
 const { lazy } = require('@squeep/lazy-property');
 
+
+/**
+ * Set up expected fields for how we handle error reporting
+ * and whatnot.
+ * @param {Object} ctx
+ */
+const initContext = (ctx) => {
+  ctx.errors = [];
+  ctx.notifications = [];
+}
+
 /**
  * Some fields may have values outside normal dates, handle them here.
  * @param {Date} date
@@ -392,6 +403,7 @@ function htmlPage(pagePathLevel, ctx, options, main = []) {
 
 
 module.exports = {
+  initContext,
   dateOrNot,
   dateFormat,
   timeElement,