pugjs / with Goto Github PK
View Code? Open in Web Editor NEWCompile time `with` for strict mode JavaScript
License: MIT License
Compile time `with` for strict mode JavaScript
License: MIT License
As seen in pugjs/pug#2409, this module is unfortunately not bug-free. It would facilitate bug-fixing for a much more important module if we bring this module under @pugjs.
In version 1.0.1 of acorn there's no util folder.
The acorn dependency is resolved in a weird way, because ^0.11.0 shouldn't resolve to 1.0.1 am I right?
Might be an issue with acorn..?
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!
> 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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.