Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow #body_class to take an optional argument of a symbol which it w…
…ill use #content_for on to add more body classes, defaults to :extra_body_classes
- Loading branch information
1 parent
371ce9d
commit ddb52a8
Showing
2 changed files
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
module BodyClassHelper | ||
def body_class | ||
def body_class(options = {}) | ||
extra_body_classes_symbol = options[:extra_body_classes_symbol] || :extra_body_classes | ||
qualified_controller_name = controller.controller_path.gsub('/','-') | ||
"#{qualified_controller_name} #{qualified_controller_name}-#{controller.action_name}" | ||
basic_body_class = "#{qualified_controller_name} #{qualified_controller_name}-#{controller.action_name}" | ||
|
||
if content_for?(extra_body_classes_symbol) | ||
[basic_body_class, content_for(extra_body_classes_symbol)].join(' ') | ||
else | ||
basic_body_class | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters