-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
I have this error: #1892
Comments
Interesting, is there any chance you could give us a copy of the jade file that results in this error? |
The code above, transforms an url into a call in a controller. The controller returns a promise that results in a call to the view with the given params (the error is in var system = require('es6-module-loader').System;
export class Router {
static loadParams(url) {
var m = url.replace(/^\//, '').split('/');
var name = m && m.length > 0 && m[0] ? m[0] : 'index';
var p = {
name: name,
controller: name.capitalize() + 'Controller',
method: m && m.length > 1 ? m[1] : 'index',
params: {}
};
if (m) {
var l = m.length;
if (l > 1 && l < 4 && !isNaN(m[l - 1])) {
p.params.id = m[l - 1];
}
else {
for (var i = 2; i < l; i += 2) {
p.params[m[i]] = (i + 1) < l ? m[i + 1] : '';
}
}
}
return p;
}
// Processamento do routeamento por defeito
static process(req, res, next) {
var p = Router.loadParams(req.path);
system.import('./app/ctr/' + p.name)
.then((ctr) => {
ctr = new ctr[p.controller](req, res);
ctr[p.method](p.params).then((data) => {
res.render('./' + p.name + '/' + p.method + '.jade', data);
});
})
.catch((err) => {
console.log('Error', err);
next();
});
}
} |
What would be extremely useful would be a copy of the jade file that causes the error. What appears to be happening is that the jade parser is producing an invalid AST that the jade compiler is therefore unable to compile, but without the original source, I have no way to reproduce the issue. If you aren't comfortable posting the jade file online, you can send it to me privately if you prefer (forbes [at] lindesay.co.uk)? |
That's ok, but the file is extremely simple. I think the error is because ObrigadoSaudações,Sérgio 2015-03-18 15:54 GMT+00:00 Forbes Lindesay [email protected]:
|
Exactly the same error happened to me :
I use jade with express, and it throw this error on every pages independently of the jade file used. I don't understand why, I don't think I've made any changes with jade files or something related. Nothing on Google.. Maybe it's update related? EDIT : Ok I feel stupid now, a ugly Object prototyping was the cause of the problem : Object.prototype.forEach = function(callback) {
for(var j in this) {
callback.apply(this[j], [j]);
}
} Removing it fixed everything, hope it'll help. |
Interesting.. I think that's probably caused by this code: // hoist mixins
for (var name in this.mixins)
ast.unshift(this.mixins[name]); in the parser, which (for your example) would try and "hoist" |
@ForbesLindesay does this mean that we need a |
Using // hoist mixins
for (var name in this.mixins)
if(this.mixins.hasOwnProperty(name))
ast.unshift(this.mixins[name]); |
We should just use |
In current master: Object.prototype.forEach = function(callback) {
for(var j in this) {
callback.apply(this[j], [j]);
}
}
var jade = require('jade')
jade.compile('doctype html') shows
The cause of this bug is acorn, which fills its options.plugins with an empty object, which isn't really empty now we add a method to its prototype. And, when accessing options.plugins it uses an unprotected for-in loop, causing this bug to occur. There is really nothing we can fix here in jade now, so closing. |
Hi. At some point of my project, this message have appeard:
The text was updated successfully, but these errors were encountered: