I want to use Rails'' caching when using Markaby
templates, but I get errors like this:
ActionView::TemplateError
(/usr/lib/ruby/gems/1.8/gems/markaby-0.5/lib/markaby/builder.rb:192:in
`method_missing'': no such method `length'') on line #0 of
app/views/items/index.mab:
1:
2: cache("#{@site.server_name}/index_items") do
Tim said:
Yep, the length error is because a lot of Rails''
internals still assume ERB, which uses a
different buffer structureto Markaby.
Looking at Rails'' code:
# Called by CacheHelper#cache
def cache_erb_fragment(block, name = {}, options
= nil)
unless perform_caching then block.call; return
end
buffer = eval("_erbout", block.binding)
if cache = read_fragment(name, options)
buffer.concat(cache)
else
pos = buffer.length
block.call
write_fragment(name, buffer[pos..-1],
options)
end
end
It seems like Markaby might have to have a "length"
attribute and/or act like "buffer"? Or would Rails
need to be changed on the eval line?
Joe
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---
Joe, This list is for the development of Rails itself. Please don''t post here for things like that. There''s a Rails-talk list for that. Kevin Clark On 11/7/06, Joe Ruby <joeat303@yahoo.com> wrote:> > I want to use Rails'' caching when using Markaby > templates, but I get errors like this: > > ActionView::TemplateError > (/usr/lib/ruby/gems/1.8/gems/markaby-0.5/lib/markaby/builder.rb:192:in > `method_missing'': no such method `length'') on line #0 of > app/views/items/index.mab: > 1: > 2: cache("#{@site.server_name}/index_items") do > > Tim said: > > Yep, the length error is because a lot of Rails'' > internals still assume ERB, which uses a > different buffer structureto Markaby. > > Looking at Rails'' code: > > # Called by CacheHelper#cache > def cache_erb_fragment(block, name = {}, options > = nil) > unless perform_caching then block.call; return > end > > buffer = eval("_erbout", block.binding) > > if cache = read_fragment(name, options) > buffer.concat(cache) > else > pos = buffer.length > block.call > write_fragment(name, buffer[pos..-1], > options) > end > end > > It seems like Markaby might have to have a "length" > attribute and/or act like "buffer"? Or would Rails > need to be changed on the eval line? > > Joe > > > > >-- Kevin Clark http://glu.ttono.us --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Actually this is rails development related: fragment caching in rails does not work other than erb template types. The error being thrown is always the same since fragment caching was built specifically targeting ERB templates. I have hit this problem when trying to fragment cache builder templates. Submitted a patch in #6642, to allow caching in Builder and Rjs templates too. Additionally extending for other templates like Foo (*.foo) would be as simple as adding a controller method like: def cache_foo_fragment(block, name) fragment_for(block, name, options) do # use eval here to retrive the generated content up to now end end For some tempate types like Markaby retrieving generated content up to a certain line is tricky. Btw kinda strange but I dont see this patch in any patch report. Zsombor Kevin Clark wrote:> Joe, > This list is for the development of Rails itself. Please don''t post > here for things like that. There''s a Rails-talk list for that. > > Kevin Clark > > On 11/7/06, Joe Ruby <joeat303@yahoo.com> wrote: >> I want to use Rails'' caching when using Markaby >> templates, but I get errors like this: >> >> ActionView::TemplateError >> (/usr/lib/ruby/gems/1.8/gems/markaby-0.5/lib/markaby/builder.rb:192:in >> `method_missing'': no such method `length'') on line #0 of >> app/views/items/index.mab: >> 1: >> 2: cache("#{@site.server_name}/index_items") do >> >> Tim said: >> >> Yep, the length error is because a lot of Rails'' >> internals still assume ERB, which uses a >> different buffer structureto Markaby. >> >> Looking at Rails'' code: >> >> # Called by CacheHelper#cache >> def cache_erb_fragment(block, name = {}, options >> = nil) >> unless perform_caching then block.call; return >> end >> >> buffer = eval("_erbout", block.binding) >> >> if cache = read_fragment(name, options) >> buffer.concat(cache) >> else >> pos = buffer.length >> block.call >> write_fragment(name, buffer[pos..-1], >> options) >> end >> end >> >> It seems like Markaby might have to have a "length" >> attribute and/or act like "buffer"? Or would Rails >> need to be changed on the eval line? >> >> Joe-- Company - http://primalgrasp.com Thoughts - http://deezsombor.blogspot.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---