I have some code to allow pages to define sub menus within their respective html files. Here''s the method I have in the application helper: def sub_menu(&block) links ||= [] links << capture(&block) @sub_menu ||= "" links.each do |link| @sub_menu += content_tag(:li, link) end @sub_menu = content_tag(:ul, @sub_menu, :class => "side_menu") @sub_menu = content_tag(:div, @sub_menu, :class => "side_menu_wrapper") # concat @sub_menu end In an html file, I can define sub menus like this: <% content_for :sub_menu do %> <% sub_menu do %> <a href="<%= new_story_path %>" class="side_button"><img src="/ images/new_story_button.png" class="centered" alt="New story!" /></a> <% end %> <% end %> This worked in Rails 2, but in Rails 3 it just displays the HTML instead of parsing it, and when I look in the source the HTML is cleaned. Here''s an example: <li> <a href="/stories/new" class="side_button"><img src="/images/ new_story_button.png" class="centered" alt="New story!" /></a> </li> How do I get around this? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sounds like you need to call .html_safe on the return value of your helper. In Rails 3, everything is automatically scrubbed. On Dec 21, 12:50 pm, Mike C <snib...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have some code to allow pages to define sub menus within their > respective html files. Here''s the method I have in the application > helper: > > def sub_menu(&block) > links ||= [] > links << capture(&block) > @sub_menu ||= "" > > links.each do |link| > @sub_menu += content_tag(:li, link) > end > > @sub_menu = content_tag(:ul, @sub_menu, :class => "side_menu") > @sub_menu = content_tag(:div, @sub_menu, :class => > "side_menu_wrapper") > > # concat @sub_menu > end > > In an html file, I can define sub menus like this: > > <% content_for :sub_menu do %> > <% sub_menu do %> > <a href="<%= new_story_path %>" class="side_button"><img src="/ > images/new_story_button.png" class="centered" alt="New story!" /></a> > <% end %> > <% end %> > > This worked in Rails 2, but in Rails 3 it just displays the HTML > instead of parsing it, and when I look in the source the HTML is > cleaned. Here''s an example: > > <li> <a href="/stories/new" > class="side_button"><img src="/images/ > new_story_button.png" class="centered" alt="New > story!" /></a> > </li> > > How do I get around this?-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
fyi, you can also pass the content into the raw() function. On Dec 21, 2010, at 1:04 PM, Garrett Lancaster wrote:> Sounds like you need to call .html_safe on the return value of your > helper. In Rails 3, everything is automatically scrubbed. > > On Dec 21, 12:50 pm, Mike C <snib...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> I have some code to allow pages to define sub menus within their >> respective html files. Here''s the method I have in the application >> helper: >> >> def sub_menu(&block) >> links ||= [] >> links << capture(&block) >> @sub_menu ||= "" >> >> links.each do |link| >> @sub_menu += content_tag(:li, link) >> end >> >> @sub_menu = content_tag(:ul, @sub_menu, :class => "side_menu") >> @sub_menu = content_tag(:div, @sub_menu, :class => >> "side_menu_wrapper") >> >> # concat @sub_menu >> end >> >> In an html file, I can define sub menus like this: >> >> <% content_for :sub_menu do %> >> <% sub_menu do %> >> <a href="<%= new_story_path %>" class="side_button"><img src="/ >> images/new_story_button.png" class="centered" alt="New story!" /></a> >> <% end %> >> <% end %> >> >> This worked in Rails 2, but in Rails 3 it just displays the HTML >> instead of parsing it, and when I look in the source the HTML is >> cleaned. Here''s an example: >> >> <li> <a href="/stories/new" >> class="side_button"><img src="/images/ >> new_story_button.png" class="centered" alt="New >> story!" /></a> >> </li> >> >> How do I get around this? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for the replies! I tried both ways and oddly enough they didn''t work... On Dec 21, 11:08 am, Garrett Lancaster <glanc...-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org> wrote:> fyi, you can also pass the content into the raw() function. > > On Dec 21, 2010, at 1:04 PM, Garrett Lancaster wrote: > > > > > Sounds like you need to call .html_safe on the return value of your > > helper. In Rails 3, everything is automatically scrubbed. > > > On Dec 21, 12:50 pm, Mike C <snib...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> I have some code to allow pages to define sub menus within their > >> respective html files. Here''s the method I have in the application > >> helper: > > >> def sub_menu(&block) > >> links ||= [] > >> links << capture(&block) > >> @sub_menu ||= "" > > >> links.each do |link| > >> @sub_menu += content_tag(:li, link) > >> end > > >> @sub_menu = content_tag(:ul, @sub_menu, :class => "side_menu") > >> @sub_menu = content_tag(:div, @sub_menu, :class => > >> "side_menu_wrapper") > > >> # concat @sub_menu > >> end > > >> In an html file, I can define sub menus like this: > > >> <% content_for :sub_menu do %> > >> <% sub_menu do %> > >> <a href="<%= new_story_path %>" class="side_button"><img src="/ > >> images/new_story_button.png" class="centered" alt="New story!" /></a> > >> <% end %> > >> <% end %> > > >> This worked in Rails 2, but in Rails 3 it just displays the HTML > >> instead of parsing it, and when I look in the source the HTML is > >> cleaned. Here''s an example: > > >> <li> <a href="/stories/new" > >> class="side_button"><img src="/images/ > >> new_story_button.png" class="centered" alt="New > >> story!" /></a> > >> </li> > > >> How do I get around this? > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.