summary refs log tree commit diff
path: root/lib/htmlbuilder.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/htmlbuilder.js')
-rw-r--r--lib/htmlbuilder.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/htmlbuilder.js b/lib/htmlbuilder.js
index 7343116..483b77b 100644
--- a/lib/htmlbuilder.js
+++ b/lib/htmlbuilder.js
@@ -32,9 +32,15 @@ function makeSigmaHtmlPlusElement(elem) {
         return elem.parentElement
     }
     elem.for = function (array, func) {
-        array.forEach(element => elem.appendChild(func(element)));
+        array.forEach((element, i) => elem.appendChild(func(element, i)));
         return elem
     }
+    elem.if = function (condition, type) {
+        if(condition) return;
+        let childElem = makeSigmaHtmlPlusElement(document.createElement(type));
+        elem.appendChild(childElem)
+        return childElem;
+    }
     return elem;
 }