Skip to content
This repository has been archived by the owner on Jan 25, 2020. It is now read-only.

when render data has properties like "views,settings,ext", it will throw errors #21

Open
winnieBear opened this issue May 21, 2014 · 7 comments

Comments

@winnieBear
Copy link

when call like this in controller,

var data = {
    "key is not views,settings,ext":"run ok "
   };
    res.render('index', data);

if data has no properties like "views,settings,ext", it can run ok,

BUT,when data has these properties,like this

var data = {
    name: 'test',
    views: 'this is test string!',
    settings: 'this is the data from models',
    ext:'but it will not ok!'
  };
  res.render('index', data);

the programe will throw errors of 503.

I find these errors is caused by adaro\lib\engine.js,adaro\lib\utils.js, in which the above three properties is used as important parameters.

But these properties name can also be used as data for render. When your data has "views,settings,ext" properties name, the programe will core.

You can git checkout my test case to verify it.

@pvenkatakrishnan
Copy link
Member

sorry for the delay. looking into this.

@pvenkatakrishnan
Copy link
Member

The reason for this being a problem is data and res.locals get merged before getting passed to view engine in express. Unfortunately, views, settings and ext are internally defined values when dust processes which collides with your definitions and hence the problem.

@pvenkatakrishnan
Copy link
Member

Agreed it is invonvenient(dust could have used something better namespaced), but is there a way you can exclude these property names ?

@aredridel
Copy link
Contributor

I think I can solve this in the adaro 1.0 release, since there's already a rescoping of some values in there.

@aks-
Copy link
Contributor

aks- commented May 15, 2015

It will be fixed. I made these changes which will be reflected in Express 5 expressjs/express#2648

@aredridel
Copy link
Contributor

Indeed. Doesn't look like it'll make the 1.0 release, since Express itself is what mixes these concerns together.

@aks-
Copy link
Contributor

aks- commented May 15, 2015

Aha, right

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants