Re: [Rails-core] Partials and helpers

2012-09-05 Thread Matt Jones

On Sep 5, 2012, at 8:47 AM, Luís Ferreira wrote:

 Hi,
 
 Is there any reason why helpers cannot render partials?
 
 I would like to do something like this in the layout:
 
 body
  %= magic_header %
 
  %= yield %
 /body
 
 and then have a magic_header helper
 
 def magic_helper
  ...do some magic...
  render partial: magic_helper
 end
 
 Why is this wrong?

What's it failing to do? I've used this pattern frequently for partials that 
need some extra argument preprocessing and haven't encountered problems.

--Matt Jones

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.



Re: [Rails-core] Partials and helpers

2012-09-05 Thread Luís Ferreira
Ups. You right. it does work, even though I had the idea it didn't.

Nonetheless, the real question was not using render, but render_to_string (or 
any ActionController helpers) that is not available from helpers.

Why is this so?
On Sep 5, 2012, at 4:30 PM, Matt Jones wrote:

 
 On Sep 5, 2012, at 8:47 AM, Luís Ferreira wrote:
 
 Hi,
 
 Is there any reason why helpers cannot render partials?
 
 I would like to do something like this in the layout:
 
 body
 %= magic_header %
 
 %= yield %
 /body
 
 and then have a magic_header helper
 
 def magic_helper
 ...do some magic...
 render partial: magic_helper
 end
 
 Why is this wrong?
 
 What's it failing to do? I've used this pattern frequently for partials that 
 need some extra argument preprocessing and haven't encountered problems.
 
 --Matt Jones
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/rubyonrails-core?hl=en.
 

Cumprimentos,
Luís Ferreira



-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.