couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zachary Zolton <zachary.zol...@gmail.com>
Subject Re: JavaScript specification changes at 0.11?
Date Thu, 25 Mar 2010 19:42:55 GMT
@Mikeal thanks for the link! I've been trying to get CommonJS
require()s going in my _list functions... (^_^)

On Thu, Mar 25, 2010 at 2:10 PM, Mikeal Rogers <mikeal.rogers@gmail.com> wrote:
> correct, "this" is now the ddoc, so if you attach templates as attributes to
> your ddoc you can pull them out with something like:
>
> this.templates['mytemplate.mustache'].
>
> The way you were using this previously is a very very bad idea because there
> are no guarantees that you won't at some point in the future be using two
> query servers to return show functions for the same ddoc.
>
> If you want to have a function that can be loaded in any view you should use
> the new commonjs modules:
>
> http://wiki.apache.org/couchdb/commonjs_modules
>
> At this time these are not cached so they will get re-evaled each time. You
> should never depend on global state in the view server because it could
> always end up be distributed to parallel instances in the future.
>
> -Mikeal
>
> On Thu, Mar 25, 2010 at 7:18 AM, Benoit Chesneau <bchesneau@gmail.com>wrote:
>
>> On Thu, Mar 25, 2010 at 3:10 PM, Paul Davis <paul.joseph.davis@gmail.com>
>> wrote:
>> > The fact that you used to be able to attach to the 'this' object was
>> > definitely just a coincidence. I'm fairly surprised it even worked
>> > consistently for you.
>> >
>> > That said, it looks like you're wanting to check out the
>> > require("path.to.stuff") method that's now available for show and
>> > list. This will let you define arbitrary JS in your _design doc and
>> > import it in your show/list functions.
>> >
>> > HTH,
>> > Paul Davis
>> >
>>
>> this is also used to acccess to the ddoc now if I remmeber.
>>
>> - benoit
>>
>

Mime
View raw message