added variables in action syntax...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-11-19 01:00:12 +03:00
parent 58b8545ce1
commit a6b66358a9
2 changed files with 10 additions and 7 deletions

View File

@ -343,11 +343,13 @@ function(func){
} }
// NOTE: identifiers are resolved as attributes of the context...
// XXX this is the same as ImageGrid's keyboard.parseActionCall(..), reuse // XXX this is the same as ImageGrid's keyboard.parseActionCall(..), reuse
// in a logical manner... // in a logical manner...
var parseStringAction = var parseStringAction =
module.parseStringAction = module.parseStringAction =
function(txt){ function(txt, context){
context = context || this
// split off the doc... // split off the doc...
var c = txt.split('--') var c = txt.split('--')
var doc = (c[1] || '').trim() var doc = (c[1] || '').trim()
@ -360,8 +362,7 @@ function(txt){
action = no_default ? action.slice(0, -1) : action action = no_default ? action.slice(0, -1) : action
// parse arguments... // parse arguments...
var args = JSON.parse('['+( var args = ((c[1] || '')
((c[1] || '')
.match(RegExp([ .match(RegExp([
// strings... // strings...
'"[^"]*"', '"[^"]*"',
@ -380,14 +381,16 @@ function(txt){
'\\d+\\.\\d+|\\d+', '\\d+\\.\\d+|\\d+',
// identifiers... // identifiers...
// XXX not JSON compatible... '[a-zA-Z$@#_][a-zA-Z0-9$@#_]*',
//'[a-zA-Z$@#_][a-zA-Z0-9$@#_]*',
// null... // null...
'null' 'null'
].join('|'), 'gm')) ].join('|'), 'gm'))
|| []) || [])
.join(','))+']') .map(function(e){
return /^[a-zA-Z$@#_][a-zA-Z0-9$@#_]*$/.test(e) ?
context[e]
: JSON.parse(e) })
return { return {
action: action, action: action,

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-actions", "name": "ig-actions",
"version": "3.9.0", "version": "3.10.0",
"description": "", "description": "",
"main": "actions.js", "main": "actions.js",
"scripts": { "scripts": {