mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Updating Vars to allow scoped anonymous functions
This commit is contained in:
parent
90fb80b71f
commit
9d5a7429c5
@ -15,6 +15,14 @@ class Vars extends Node {
|
|||||||
var declarations = this.declarations;
|
var declarations = this.declarations;
|
||||||
var kind = this.kind;
|
var kind = this.kind;
|
||||||
var isStatement = this.statement;
|
var isStatement = this.statement;
|
||||||
|
var body = this.body;
|
||||||
|
var selfInvoking = this.isFlagSet('selfInvoking');
|
||||||
|
var hasBody = (body && body.array && body.array.length > 0);
|
||||||
|
|
||||||
|
if(!selfInvoking && hasBody) {
|
||||||
|
this.setFlag('selfInvoking');
|
||||||
|
return generator.builder.selfInvokingFunction([ this ]);
|
||||||
|
}
|
||||||
|
|
||||||
if (declarations && !Array.isArray(declarations) && typeof declarations === 'object') {
|
if (declarations && !Array.isArray(declarations) && typeof declarations === 'object') {
|
||||||
// Convert the object into an array of variables
|
// Convert the object into an array of variables
|
||||||
@ -77,6 +85,9 @@ class Vars extends Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(hasBody) {
|
||||||
|
generator.generateCode(body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
FRANK 3650
|
FRANK 36501711
|
||||||
@ -1,3 +1,8 @@
|
|||||||
<var name='Frank' age=10/>
|
<var name='Frank' age=10/>
|
||||||
|
|
||||||
${name.toUpperCase()} ${age*365}
|
${name.toUpperCase()} ${age*365}
|
||||||
|
<var x=1 y=7 z=x+10 unusedVar>
|
||||||
|
${x}
|
||||||
|
${y}
|
||||||
|
${z}
|
||||||
|
</var>
|
||||||
Loading…
x
Reference in New Issue
Block a user