Coder Social home page Coder Social logo

with's People

Contributors

cspotcode avatar forbeslindesay avatar jonathanong avatar ppitonak avatar timothygu avatar zackschuster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

with's Issues

Ambiguous errors when "let" and "const" rules are violated

Hello,
It took me a while to figure out the cause of this error:

Error: Error parsing body of the with expression
    at addWith (...\node_modules\with\lib\index.js:50:29)
    at Compiler.compile (...\node_modules\pug-code-gen\index.js:139:12)
    at generateCode (...\node_modules\pug-code-gen\index.js:32:37)
    at compileBody (...\node_modules\pug\lib\index.js:199:74)
    at Object.exports.compile (...\node_modules\pug\lib\index.js:269:16)
    at handleTemplateCache (...\node_modules\pug\lib\index.js:242:25)
    at Object.exports.renderFile (...\node_modules\pug\lib\index.js:454:10)
    at Object.exports.renderFile (...\node_modules\pug\lib\index.js:444:21)
    at View.exports.__express [as engine] (...\node_modules\pug\lib\index.js:493:11)
    at View.render (...\node_modules\express\lib\view.js:135:8)

because I had two separate templates in a case/when block, so I didn't think that using let to define variables of the same name would raise an error. Anyways, to reproduce the error, all you have to do is:

- let foo = 'bar';
- let foo = 'bar 2';

or

- const foo = 'bar';
- let foo = 'bar 2';

or

- var foo = 'bar';
- let foo = 'bar 2';

Essentially any combination of variable declarations in the same block, except when using exclusively var, leads to the ambiguous "Error parsing body of the with expression" message. Ideally, something similar to what JS does natively would be great: Identifier 'foo' has already been declared - or at least pointing to the problematic line of code.

I'm using PugJS v3.0.2, which appears to use With v7.0.0.

Thanks!

"undefined" in obj when `this` is referenced

> addWith('obj', 'return this.value')
';;var result_of_with=(function (undefined) {return {value: this.value};}.call(this,"undefined" in obj?obj.undefined:typeof undefined!=="undefined"?undefined:undefined));if (result_of_with) return result_of_with.value;'

most of this is unnecessary as .call(this will handle this case.

Backwards compatibility break due to acorn dependency

The latest acorn release (1.0.1) breaks compatibility with the previous 0.x releases: acornjs/acorn#235

The current version of this package (4.0.2) depends on a version compatible with 1.0.1, thus breaking compatibility without increasing its own major version.

In practice, this breaks our jade templates that contain variable names clashing with reserved keywords.

The only way I can think of fixing this is releasing 4.0.3 depending back on 0.11.x, and 5.0.x depending on 1.0.1, but hopefully there's a less intrusive way of doing so.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.