diff --git a/src/highlight-customize/expression.js b/src/highlight-customize/expression.js index 9b814d2d..6754eed2 100644 --- a/src/highlight-customize/expression.js +++ b/src/highlight-customize/expression.js @@ -192,6 +192,17 @@ function mathExpr(expr, portal) { return null; } +function pathExpr(expr, portal) { + const path = expr[0]; + const obj = evaluateExpr(expr[1], portal); + + if (typeof(obj) === 'object') + return obj[path]; + + return null; +} + + /** Retrieve the value of the property `prop` of the portal */ function getExpr(expr, portal) { const prop = expr[1]; @@ -257,6 +268,8 @@ const operators = { rgb: rgbExpr, // array slice: sliceExpr, + // obj/array + path: pathExpr, }; export function evaluateExpr(expr, portal) { diff --git a/src/highlight-customize/meta.json b/src/highlight-customize/meta.json index 12e8a30f..7d68674a 100644 --- a/src/highlight-customize/meta.json +++ b/src/highlight-customize/meta.json @@ -2,6 +2,6 @@ "author": "jaiperdu", "name": "Customized highlighter", "category": "Highlighter", - "version": "0.2.2", + "version": "0.2.3", "description": "Configure you own highlighter" }