Skip to content

Commit

Permalink
feat: $template condition checks for {{}}
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Jun 17, 2024
1 parent fc10c27 commit bd7219a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// you must obtain a commercial license from CoCreate LLC.
// For details, visit <https://cocreate.app/licenses/> 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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit bd7219a

Please sign in to comment.