widgets: props: add experimental #{} syntax for anywhere mathjs expression
This commit is contained in:
parent
53b3dddade
commit
1e7d13c279
1 changed files with 8 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ var EventEmitter = require('../../events/event-emitter'),
|
|||
osc = require('../../osc'),
|
||||
shortid = require('shortid'),
|
||||
widgetManager = require('../../managers/widgets'),
|
||||
{math} = require('../utils'),
|
||||
updateWidget = function(){ updateWidget = require('../../editor/data-workers').updateWidget; updateWidget(...arguments)}
|
||||
|
||||
|
||||
|
|
@ -267,6 +268,13 @@ module.exports = class _widgets_base extends EventEmitter {
|
|||
|
||||
})
|
||||
|
||||
try {
|
||||
propValue = propValue.replace(/#\{([^\}]+)\}/g, (m)=>{
|
||||
let expression = m.substr(2, m.length - 3).trim()
|
||||
return math.eval(expression)
|
||||
})
|
||||
} catch (err) {}
|
||||
|
||||
try {
|
||||
propValue = JSON.parse(propValue)
|
||||
} catch (err) {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue