feat(core): Pass shorthand to macros
This commit is contained in:
parent
89d491fb48
commit
d1f7db8cad
1 changed files with 8 additions and 6 deletions
|
@ -128,7 +128,6 @@ Part.prototype.shorthand = function () {
|
||||||
getId: this.getId,
|
getId: this.getId,
|
||||||
hide: this.hide,
|
hide: this.hide,
|
||||||
log: this.context.store.log,
|
log: this.context.store.log,
|
||||||
macro: this.__macroClosure(),
|
|
||||||
paperless,
|
paperless,
|
||||||
part: this,
|
part: this,
|
||||||
sa,
|
sa,
|
||||||
|
@ -209,6 +208,9 @@ Part.prototype.shorthand = function () {
|
||||||
set: (absoluteOptions, name, value) => (self.context.settings.absoluteOptions[name] = value),
|
set: (absoluteOptions, name, value) => (self.context.settings.absoluteOptions[name] = value),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Macro closure at the end as it includes the shorthand object
|
||||||
|
shorthand.macro = this.__macroClosure(shorthand)
|
||||||
|
|
||||||
return shorthand
|
return shorthand
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,11 +334,11 @@ Part.prototype.__inject = function (orig) {
|
||||||
* @private
|
* @private
|
||||||
* @return {function} method - The closured macro method
|
* @return {function} method - The closured macro method
|
||||||
*/
|
*/
|
||||||
Part.prototype.__macroClosure = function () {
|
Part.prototype.__macroClosure = function (props) {
|
||||||
let self = this
|
const self = this
|
||||||
let method = function (key, args) {
|
const method = function (key, args) {
|
||||||
let macro = utils.__macroName(key)
|
const macro = utils.__macroName(key)
|
||||||
if (typeof self[macro] === 'function') self[macro](args)
|
if (typeof self[macro] === 'function') self[macro](args, props)
|
||||||
}
|
}
|
||||||
|
|
||||||
return method
|
return method
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue