Sha256: cee8cdc77f1753d7e9786843677ad0f6872b20238d074b2e2648f6964beb32f6
Contents?: true
Size: 846 Bytes
Versions: 10
Compression:
Stored size: 846 Bytes
Contents
module RailsStuff module Helpers module Text # Replaces blank values with cached placeholder from translations. # When called with block, it'll check value for blankness, but returns # block's result if value is present. # # replace_blank(description) # replace_blank(tags) { tags.join(', ') } # replace_blank(order.paid_at) { |x| l x, format: :long } # def replace_blank(value, &block) if value.blank? blank_placeholder else block_given? ? capture(value, &block) : value end end # Default placeholder value. def blank_placeholder @_blank_placeholder ||= content_tag :small, "(#{I18n.t(:'helpers.placeholder.blank', default: '-')})", class: :'text-muted' end end end end
Version data entries
10 entries across 10 versions & 1 rubygems