Better page_title helper handling for nested blocks
This commit is contained in:
@@ -90,17 +90,18 @@ module Dunlop
|
||||
scope_model.human_attribute_name(attribute_name)
|
||||
end
|
||||
|
||||
def page_title(*args)
|
||||
res = content_tag :h3, class: 'page-title ui header' do
|
||||
if resource_title?(args)
|
||||
@scope_model = args[1].is_a?(ActiveRecord::Base) ? args[1].class : args[1]
|
||||
page_title_for_resource(args)
|
||||
else
|
||||
page_title_for_string(args)
|
||||
end
|
||||
def page_title(*args, &blk)
|
||||
extra_content = capture(&blk) if blk.present?
|
||||
if resource_title?(args)
|
||||
@scope_model = args[1].is_a?(ActiveRecord::Base) ? args[1].class : args[1]
|
||||
content = page_title_for_resource(args)
|
||||
else
|
||||
content = page_title_for_string(args)
|
||||
end
|
||||
content_for :page_title, res
|
||||
res
|
||||
content += extra_content if extra_content.present?
|
||||
title_tag = content_tag(:h3, content, class: 'page-title ui header')
|
||||
content_for :page_title, title_tag
|
||||
title_tag
|
||||
end
|
||||
|
||||
def resource_title?(args)
|
||||
@@ -109,7 +110,7 @@ module Dunlop
|
||||
end
|
||||
|
||||
def page_title_for_string(args)
|
||||
title = args.first
|
||||
title = html_escape(args.first)
|
||||
options = args.last.is_a?(Hash) ? args.last : {}
|
||||
if back_options = options[:back]
|
||||
url =
|
||||
@@ -120,7 +121,7 @@ module Dunlop
|
||||
end
|
||||
if url
|
||||
back_link = link_to content_tag(:i, nil, class: 'left arrow icon'), url, class: 'title-back-link'
|
||||
title = [back_link, title].join.html_safe
|
||||
title = back_link.safe_concat(title)
|
||||
end
|
||||
end
|
||||
title
|
||||
@@ -130,9 +131,9 @@ module Dunlop
|
||||
options = args.extract_options!
|
||||
model = args[1].respond_to?(:model_name) ? args[1] : args[1].class
|
||||
if args.first == :index
|
||||
title = t('action.index.label', models: model.model_name.human_plural)
|
||||
title = t('action.index.label', models: model.model_name.human_plural).html_safe
|
||||
else
|
||||
title = t("action.#{args.first}.label", model: model.model_name.human)
|
||||
title = t("action.#{args.first}.label", model: model.model_name.human).html_safe
|
||||
end
|
||||
if back_options = options[:back]
|
||||
url =
|
||||
@@ -143,7 +144,7 @@ module Dunlop
|
||||
end
|
||||
if url
|
||||
back_link = link_to content_tag(:i, nil, class: 'left arrow icon'), url, class: 'title-back-link'
|
||||
title = [back_link, title].join.html_safe
|
||||
title = back_link.safe_concat(title)
|
||||
end
|
||||
end
|
||||
title
|
||||
|
||||
Reference in New Issue
Block a user