by trevelyan · 15y ago · 0 comments
This gives a max of two css files per page. For the landing page I compress the generic file along with the controller-specific css file for the default page into a single file. This speeds up the loading process while preventing too much bloat. Since the other pages are usually hit after the landing page they require only a single extra download. Any reset code can be included in there as well, although maintained as a separate file.
I doubt this approach is ideal when it comes to organizing things, but it's fairly fast when it comes to development. I design by including css in style="" and then refactoring the markup into classes once the design is complete. Saves a lot of back and forth while getting things lined up.
Using Haml:
%body(class="#{controller.controller_name} #{controller.action_name}")
Using Erb: <body class ='<%= "#{controller.controller_name} #{controller.action_name}"%>'>