Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marko v3: var tag #169

Closed
patrick-steele-idem opened this Issue Dec 8, 2015 · 0 comments

Comments

Projects
None yet
2 participants
@patrick-steele-idem
Copy link
Contributor

patrick-steele-idem commented Dec 8, 2015

Single unscoped variable:

<var x=1 />

Output JavaScript code:

var x=1;

Single unscoped variable with no init value:

<var x />

Output JavaScript code:

var x;

Multiple unscoped variables:

<var x=1 y=7 z=x+10 unusedVar/>

Output JavaScript code:

var x=1,
    y=7,
    z=x+10,
    unusedVar;

Scoped variables:

<var x=1 y=7 z=x+10 unusedVar>
  ${x}
  ${y}
  ${z}
</var>
${x} <!-- Runtime error! Uncaught ReferenceError: x is not defined -->

Output JavaScript code when using scoped variables:

(function() {
    var x=1,
        y=7,
        z=x+10,
        unusedVar;
   ...
}())

Important: As part of a more powerful <var> tag we should drop support for the <with> tag and the @with attribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.