On Tue, Feb 16, 2010 at 11:05 AM, Zachary Zolton
<[email protected]> wrote:
> Should the require path start from the root of the ddoc object? Or
> should we create an arbitrary first term in the namespace?
>
> Given the design document:
> { "foo": "bar" }
>
> Should it be require("foo") or require("ddoc/foo") to get at "bar"?
>

I like "ddoc/foo" because in the future people may want to include
standard libraries in their couchjs server. Also having ddoc in the
code makes it clear where to put stuff if you want it to show up.

Chris

> -ZZ
>
> On Tue, Feb 16, 2010 at 11:58 AM, Chris Anderson <[email protected]> wrote:
>> On Tue, Feb 16, 2010 at 9:25 AM, Filipe David Manana <[email protected]> 
>> wrote:
>>> Chris,
>>>
>>> looking at render.js:
>>>
>>>  function runShow(fun, ddoc, args) {
>>>    try {
>>>      resetList();
>>>      Mime.resetProvides();
>>>      var resp = fun.apply(ddoc, args) || {};
>>
>> Cool, looks like the work is already done. If anyone wants to write a
>> version of CommonJS require() that uses 'this' to load code from the
>> ddoc, it looks like the foundations are already laid.
>>
>> Chris
>>
>>>
>>> The scope under which the show function is executed is in fact the design
>>> doc. Same goes for _list, _update and _validate.
>>>
>>>
>>>
>>> On Tue, Feb 16, 2010 at 1:56 AM, J Chris Anderson <[email protected]> wrote:
>>>
>>>>
>>>> the design doc is available in the view server (in everything but map and
>>>> reduce functions), but it's not exposed to the sandbox (yet).
>>>>
>>>> I'd like to make it so the design doc is the value of 'this' when you are
>>>> inside _show, _list, etc functions.
>>>>
>>>> This would be a small patch if anyone is up for it.
>>>>
>>>> Chris
>>>>
>>>> >
>>>> >
>>>> > Cheers,
>>>> >
>>>> > Zach
>>>>
>>>>
>>>
>>>
>>> --
>>> Filipe David Manana,
>>> [email protected]
>>> PGP key - http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC569452B
>>>
>>> "Reasonable men adapt themselves to the world.
>>> Unreasonable men adapt the world to themselves.
>>> That's why all progress depends on unreasonable men."
>>>
>>
>>
>>
>> --
>> Chris Anderson
>> http://jchrisa.net
>> http://couch.io
>>
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Reply via email to