Module: Padrino::Admin::Helpers::ViewHelpers

Defined in:
padrino-admin/lib/padrino-admin/helpers/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#model_attribute_translate(model, attribute) ⇒ String Also known as: t_attr

Translates attribute name for the given model.

Examples:

# => t("models.account.attributes.email", :default => "Email")
mat(:account, :email)


62
63
64
# File 'padrino-admin/lib/padrino-admin/helpers/view_helpers.rb', line 62

def model_attribute_translate(model, attribute)
  t("models.#{model}.attributes.#{attribute}", :default => attribute.to_s.humanize)
end

#model_translate(model) ⇒ String Also known as: mt

Translates model name.

Examples:

# => t("models.account.name", :default => "Account")
mt(:account)


80
81
82
# File 'padrino-admin/lib/padrino-admin/helpers/view_helpers.rb', line 80

def model_translate(model)
  t("models.#{model}.name", :default => model.to_s.humanize)
end

#padrino_admin_translate(word, *args) ⇒ String Also known as: pat

Translates a given word for padrino admin.

Examples:

# => t("padrino.admin.profile",  :default => "Profile")
pat(:profile)

# => t("padrino.admin.profile",  :default => "My Profile")
pat(:profile, "My Profile")


41
42
43
44
45
# File 'padrino-admin/lib/padrino-admin/helpers/view_helpers.rb', line 41

def padrino_admin_translate(word, *args)
  options = args.extract_options!
  options[:default] ||= word.to_s.humanize
  t("padrino.admin.#{word}", options)
end

#tag_icon(icon, tag = nil) ⇒ String

Icon's Bootstrap helper.

Examples:

tag_icon(:edit, :list)


19
20
21
22
# File 'padrino-admin/lib/padrino-admin/helpers/view_helpers.rb', line 19

def tag_icon(icon, tag = nil)
  content = (:i, '', :class=> "fa fa-#{icon}")
  content << " #{tag}"
end