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)

Parameters:

  • model (Symbol)

    The model name for the translation.

  • attribute (Symbol)

    The attribute name in the model to translate.

Returns:

  • (String)

    The translated attribute name for the current locale.



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)

Parameters:

  • attribute (Symbol)

    The attribute name in the model to translate.

Returns:

  • (String)

    The translated model name for the current locale.



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")

Parameters:

  • word (String)

    The specified word to admin translate.

  • default (String)

    The default fallback if no word is available for the locale.

Returns:

  • (String)

    The translated word for the current locale.



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.last.is_a?(Hash) ? args.pop : {}
  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)

Parameters:

  • icon (Symbol)

    The specified icon type.

  • tag (Symbol) (defaults to: nil)

    The HTML tag.

Returns:

  • (String)

    HTML tag with prepend icon



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