summaryrefslogtreecommitdiff
path: root/app/helpers/application_helper.rb
diff options
context:
space:
mode:
authorSemyon Pupkov <mail@semyonpupkov.com>2017-02-12 13:02:26 +0500
committerSemyon Pupkov <mail@semyonpupkov.com>2017-02-15 14:29:48 +0500
commit0dfccd995aa9bf560e59299f3a4f1705d6981115 (patch)
treec6ab80041dd2b83ed4c245b0824c2ace70872eb2 /app/helpers/application_helper.rb
parent1452729304393978ec93b712130dff6687db01b9 (diff)
downloadgitlab-ce-0dfccd995aa9bf560e59299f3a4f1705d6981115.tar.gz
Add active_when helper
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/24036
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r--app/helpers/application_helper.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index bee323993a0..6db813d4a02 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -296,4 +296,13 @@ module ApplicationHelper
def page_class
"issue-boards-page" if current_controller?(:boards)
end
+
+ # Returns active css class when condition returns true
+ # otherwise returns nil.
+ #
+ # Example:
+ # %li{ class: active_when(params[:filter] == '1') }
+ def active_when(condition)
+ 'active' if condition
+ end
end