On Thu, 2012-08-30 at 15:20 -0400, Nicolas LE BAS wrote:
> > My preference is for the first approach, and particularly standardising
> > on using Request.class.getName() as the key in foreign contexts.
> > 
> > But there often isn't a foreign context that is loose enough to put a
> > request object into. I would rather have taken the first approach in
> > tiles-request-mustache but it doesn't seem possible. Using a ThreadLocal
> > should be a frowned upon last-available option to use. 
> 
> How about:
>     protected Map<String,Object> buildScope(Request request) {
>         [...retrieve attributes...]
>         scope.put(Request.class.getName(), request);
>         return scope;
>     }
> Wouldn't it fit the bill? 

You're quite right – i didn't do a decent job of explaining what's
actually required.

It's actually the resource loading functionality that i'm after in an
override of DefaultMustacheFactory.getReader(String path).

This is tiles-framework code, where a path can be interpretted as a
tiles attribute name and so from the request i can obtain the
attributeContext and then do the resource loading.

I could have done a brand new implementation of MustacheFactory to make
easier access to the servlet Request object, but at these stage i'd
rather say close to the default classes mustache comes with.

But maybe 
 scope.put(Request.class.getName(), request);
should also be done here and documented as preferred?

~mck


-- 
"This above all: to thine own self be true. It must follow that you
cannot then be false to any man." Shakespeare 

| http://github.com/finn-no | http://tech.finn.no |


Reply via email to