diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-07-28 11:21:58 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-07-28 11:21:58 +0000 |
commit | 2f9050115b6f5064fb563c95757639448fccfe43 (patch) | |
tree | f40332f350d9141cee271de9c284e05ba6c647fc /app | |
parent | 37003787646589d8f55a0f40886ce1da4485b316 (diff) | |
download | redmine-2f9050115b6f5064fb563c95757639448fccfe43.tar.gz redmine-2f9050115b6f5064fb563c95757639448fccfe43.zip |
Adds a helper for building h2 tags and setting html_title (#14517).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12048 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/application_helper.rb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 62e7b2697..b918a47e8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -449,12 +449,31 @@ module ApplicationHelper end end + # Returns a h2 tag and sets the html title with the given arguments + def title(*args) + strings = args.map do |arg| + if arg.is_a?(Array) && arg.size >= 2 + link_to(*arg) + else + h(arg.to_s) + end + end + html_title args.reverse.map {|s| (s.is_a?(Array) ? s.first : s).to_s} + content_tag('h2', strings.join(' » ').html_safe) + end + + # Sets the html title + # Returns the html title when called without arguments + # Current project name and app_title and automatically appended + # Exemples: + # html_title 'Foo', 'Bar' + # html_title # => 'Foo - Bar - My Project - Redmine' def html_title(*args) if args.empty? title = @html_title || [] title << @project.name if @project title << Setting.app_title unless Setting.app_title == title.last - title.select {|t| !t.blank? }.join(' - ') + title.reject(&:blank?).join(' - ') else @html_title ||= [] @html_title += args |