caolan/kanso — Issue #300: add view loading package
Author: caolan
Created: 2011-11-02 20:40:27+00:00
State: open

Views don't behave properly inside modules, they got converted to strings and executed without the module context. To avoid confusion they should be located in a separate views directory in the format:

{
map: function (doc) { ... },
reduce: function ...
}

inside views/*.js, that way the require function call is forced inside the map and reduce functions. It also make the use of views/lib nicer for modules, currently most people would have the views located in lib/views.js and view-accessible modules inside views/lib/*.js, that seems strange, having the views not in the views directory. This would mean working around the issue that the views directory is directly loaded as modules when using views/lib though.