app/helpers/titler/titler_helper.rb in titler-1.2.0 vs app/helpers/titler/titler_helper.rb in titler-1.3.0
- old
+ new
@@ -1,9 +1,9 @@
module Titler
module TitlerHelper
def page_title(page_title)
- content_for(:page_title) {page_title}
+ content_for(:page_title) { page_title }
end
def titler(custom_vars = {})
context = controller.view_assigns.merge(custom_vars).symbolize_keys
Title.new(
@@ -22,11 +22,11 @@
@context = context
@configuration = Titler.configuration
end
def to_s
- th = title_hash = Hash.new
+ th = {}
th[:env_prefix] = env_prefix
th[:admin_namespace] = admin_namespace
th[:title_body] = title_body
th[:app_name] = app_name
th[:app_tagline] = app_tagline
@@ -35,18 +35,18 @@
private
def env_prefix
if @configuration.use_env_prefix
- Rails.env.production? ? '' : "(#{Rails.env[0,1].upcase}) "
+ Rails.env.production? ? "" : "(#{Rails.env[0, 1].upcase}) "
else
- ''
+ ""
end
end
def admin_namespace
- admin_namespace? ? admin_default_name + delimiter : ''
+ admin_namespace? ? admin_default_name + delimiter : ""
end
def admin_namespace?
@controller.class.ancestors.include?(@configuration.admin_controller)
end
@@ -54,42 +54,46 @@
def admin_default_name
@configuration.admin_name
end
def delimiter
- if @i18n.exists?('titler.delimiter') && @i18n.t('titler.delimiter').present?
- @i18n.t('titler.delimiter')
+ if @i18n.exists?("titler.delimiter") && @i18n.t("titler.delimiter").present?
+ @i18n.t("titler.delimiter")
else
@configuration.delimiter
end
end
def app_name
- if @i18n.exists?('titler.app_name') && @i18n.t('titler.app_name').present?
- @i18n.t('titler.app_name')
+ if @i18n.exists?("titler.app_name") && @i18n.t("titler.app_name").present?
+ @i18n.t("titler.app_name")
else
Rails.application.class.to_s.split("::").first
end
end
def app_tagline
- tagline = @i18n.exists?('titler.app_tagline') ? @i18n.t('titler.app_tagline') : ''
+ @i18n.exists?("titler.app_tagline") ? @i18n.t("titler.app_tagline") : ""
end
def title_body
if @title_as_set.present?
@title_as_set
else
- @controller.controller_name.titleize + ' ' + @controller.action_name.titleize rescue ''
+ begin
+ @controller.controller_name.titleize + " " + @controller.action_name.titleize
+ rescue
+ ""
+ end
end
end
def build_title_str(th)
case @configuration.app_name_position
- when 'append'
+ when "append"
th[:env_prefix] + th[:admin_namespace] + th[:title_body] + app_tagline_str(th) + app_name_str(th)
- when 'prepend'
+ when "prepend"
th[:env_prefix] + app_name_str(th) + app_tagline_str(th) + th[:admin_namespace] + th[:title_body]
else
th[:env_prefix] + th[:admin_namespace] + th[:title_body] + app_tagline_str(th)
end
end
@@ -97,28 +101,28 @@
def app_name_str(th)
if title_body.blank?
th[:app_name]
else
case @configuration.app_name_position
- when 'append'
+ when "append"
delimiter + th[:app_name]
- when 'prepend'
+ when "prepend"
th[:app_name] + delimiter
else
- ''
+ ""
end
end
end
def app_tagline_str(th)
tagline = th[:app_tagline]
if tagline.blank? || !@configuration.use_app_tagline
- ''
+ ""
else
case @configuration.app_name_position
- when 'append'
+ when "append"
delimiter + tagline
- when 'prepend'
+ when "prepend"
tagline + delimiter
end
end
end
end