From bd7219a03b5d1b04772596872af15351bfd5f999 Mon Sep 17 00:00:00 2001 From: frankpagan Date: Mon, 17 Jun 2024 16:00:55 -0400 Subject: [PATCH] feat: $template condition checks for {{}} --- src/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 7aa687e..dec79c5 100644 --- a/src/index.js +++ b/src/index.js @@ -20,7 +20,7 @@ // you must obtain a commercial license from CoCreate LLC. // For details, visit or contact us at sales@cocreate.app. -import { queryElements, checkMediaQueries, queryData } from '@cocreate/utils'; +import { queryElements, queryData } from '@cocreate/utils'; import action from '@cocreate/actions'; import observer from '@cocreate/observer'; import '@cocreate/element-prototype'; @@ -289,6 +289,7 @@ const CoCreateEvents = { //TODO: improved resize toggling of values // let hasCondition = this.elements2.get(element) if (ifCondition && evaluateCondition(ifCondition, ifValue)) { + // if (hasCondition && hasCondition.condition === ifCondition) { // return // } else @@ -588,7 +589,9 @@ function checkCondition(condition, value) { condition = parseCondition(condition); let result; - if (Array.isArray(value) && !(typeof condition === 'object')) { + if (condition === '$template') { + result = (/{{\s*([\w\W]+)\s*}}/g.test(value[0])) + } else if (Array.isArray(value) && !(typeof condition === 'object')) { if (operatorMatch) { condition = parseFloat(condition) result = value.some(v => {