Access the name of the current layout from a view?

You can use yield if you know there’s going to be something there. For example:

<%= stylesheet_link_tag “templates/#{yield :section_css}” %>

Then in your view, do this:

<% content_for :section_css do %>my_css_file_name<% end %>

If you really want to push this to the controller, I think you can still set @content_for_foo so that:

@content_for_section_css = ‘my_css_file_name’

should have the same effect as setting it in the view.

If you forget to set the section_css, though, you’ll have a stylesheet link to nowhere :slight_smile: