You meant haml_concat, right? Even doing that, the caching appears to be defeated as compared to rendering the partial directly out of the Haml view. I'm rendering about 200 rows (I know, who does *that*?) in about 430ms with the helper but about 368ms rendering the partial directly out of the view.
Obviously, using a helper is prettier and easier to test/debug but the performance penalty was striking enough to make me take a second look, even at this phase of development. I wish I knew a way to keep the logic in the helper but preserve all the performance goodness of what you seen in the code snippet below/ Steve On Nov 14, 2010, at 8:34 PM, Nathan Weizenbaum wrote: > In general, using a template allows Haml's optimization mechanisms to kick > in, prerendering all the HTML it can. If you just haml_puts the result of the > #render call, that should perform better. > > On Sun, Nov 14, 2010 at 8:03 PM, steve ross <[email protected]> wrote: > On Nov 14, 2010, at 2:26 PM, Nathan Weizenbaum wrote: > > > capture_haml only captures strings that are concatenated directly to the > > template. render :partial actually returns the string result rather than > > concatenating it, so that's why capture_haml isn't working here. > > > > On Sun, Nov 14, 2010 at 1:22 PM, steve ross <[email protected]> wrote: > > In a helper that renders partials can I use capture_haml? > > > > e.g., > > > > def mapped_downloads(download_hash) > > s = capture_haml do > > download_hash.map do |date, downloads| > > downloads.sort{|o, other| other[:id] <=> o[:id]}.each do |d| > > render :partial => 'detail_row', :locals => {:d => d, :date => > > date} if d.download_date > 15.days.ago.to_date || Rails.env == 'test' > > end > > render :partial => 'subtotal', :locals => {:downloads => downloads, > > :date => date} > > end > > end > > s > > end > > > > I'm not seeing anything from: > > > > = mapped_downloads(@downloads) > > > > in my view code. Help? > > \ > > Thanks Nathan. > > I rewrote this, expressing the contents of the partials in methods contained > in the helper using haml_puts. Oddly, the performance suffered. Is there any > caching goodness associated with using render or is this something that's > buried someplace in my code. > > -- -- You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/haml?hl=en.
