figma-plugin icon indicating copy to clipboard operation
figma-plugin copied to clipboard

Fix: Allow expressions to return string and boolean values

Open LukeFinch opened this issue 6 months ago • 1 comments

What does this pull request do?

Currently, we're unable to use logic to return boolean values or strings when using expr-eval

  • Evaluated can be number, string or boolean.
  • Added tests for string and boolean expressions

Testing this change

{
  "str": {
    "value": "true ? 'yes' : 'no'",
    "type": "other"
  },
  "three-bigger-than-two": {
    "value": "3 > 2 ? true : false",
    "type": "other"
  }
}

Create these tokens, values should return yes and true In previous versions, checkAndEvaluateMaths would not parse these values properly.

Additional Notes (if any)

I'm also looking into how arrays could be handled, as I feel the map() function from expr-eval could be useful

LukeFinch avatar Aug 17 '24 13:08 LukeFinch