Module: LocaleMailer::ActionViewHelpers
- Defined in:
- lib/locale_mailer/actionview_helpers.rb
Instance Method Summary collapse
-
#array_to_tags(array, tag_name = nil) ⇒ Object
Build a collection of tags from an array todo : Check potential security issue here, use with caution.
-
#t(*args) ⇒ Object
Allow t to parse array retrieved from locale.
-
#text(locale, opts = {}) ⇒ Object
Retrieve and wrap a locale into a tag (p per default) If the locale sends back an array, build a collection of tags.
Instance Method Details
#array_to_tags(array, tag_name = nil) ⇒ Object
Build a collection of tags from an array todo : Check potential security issue here, use with caution
30 31 32 33 34 35 36 37 38 |
# File 'lib/locale_mailer/actionview_helpers.rb', line 30 def array, tag_name = nil Array.wrap(array).flatten.map do |line| if tag_name content_tag tag_name, line.to_s.html_safe else line.to_s.html_safe end end.join.html_safe end |
#t(*args) ⇒ Object
Allow t to parse array retrieved from locale
16 17 18 19 20 21 22 23 24 |
# File 'lib/locale_mailer/actionview_helpers.rb', line 16 def t *args str = super opts = args..except(:throw, :raise) if str.is_a?(Array) and not opts.empty? str.map { |item| I18n.interpolate(item, opts) unless item.nil? }.map(&:to_s) else str end end |
#text(locale, opts = {}) ⇒ Object
Retrieve and wrap a locale into a tag (p per default) If the locale sends back an array, build a collection of tags
8 9 10 11 |
# File 'lib/locale_mailer/actionview_helpers.rb', line 8 def text locale, opts = {} tag = opts.key?(:tag) ? opts.delete(:tag) : :p t(locale, opts), tag end |