module Spyro::ActionViewExtension::PageTitle
Public Instance Methods
page_title(key, options)
click to toggle source
# File lib/spyro/helpers/action_view_extension.rb, line 696 def page_title key, options prefix = I18n.t('page_title.prefix', :raise => true) rescue [] suffix = I18n.t('page_title.suffix', :raise => true) rescue [] key = [*key] title = "" while key.any? and title.blank? title = I18n.t(['page_title', *key].join('.'), :raise => true) rescue nil key.pop if key.last == "default" key[-1] = "default" if key.any? end title = (title.blank? ? options[:default] : [prefix, title, suffix].flatten.compact.join(options[:separator] || ' - ')) title.gsub(/\{\{([^\}]+)\}\}/) { $1.split('.').inject(self) { |base, method| base.send(method) } } rescue options[:default].gsub(/\{\{([^\}]+)\}\}/) { $1.split('.').inject(self) { |base, method| base.send(method) } } end