Hello,

I have a little challenge that is frustrating me. I am trying to write  
a wrapper around cache() so that my fragments get cached with comments  
injected at the front and back. Unfortunately it is not as simple as  
using "concat(text,block.bindings)" before and after the call to  
cache() because then the comments themselves don't get cached.

Here is what I have right now:

   def wrap_cache(path,&block)
     concat("<!-- start fragment for #{path} -->", block.binding)
     cache(path,&block)
     concat("<!-- end fragment for #{path} -->", block.binding)
   end

It produces the correct visual output, but the concat results aren't  
part of the cached fragment, they are getting regenerated every time.  
What I need to do is something like this:

   def wrap_cache2(path,&block)
     cache(path) do
       concat(label_frag('vvvvvvvvv',path),block.binding)
       yield
       concat(label_frag('^^^^^^^^^',path),block.binding)
     end
   end

But I need to give this new block the bindings of the original block,  
rather than have it grab a new set of bindings. With the above,  
cache() crashes b/c the inner block isn't in the context of an erb  
template, so it's missing key stuff (specifically _erbout).

-Avram

"I realised something was wrong when I looked over and saw the mast in  
the water." - Dean Barker, Team New Zealand skipper


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to