Sha256: 30d8158bf4d01fdbc7053cb8addcfcfb8188976b7d82b3190dddfe736943d2fa
Contents?: true
Size: 975 Bytes
Versions: 1
Compression:
Stored size: 975 Bytes
Contents
module Rich module I18n module Core class EnrichedString delegate :empty?, :blank?, :to_json, :to => :@string def initialize(string = "", meta_data = nil) @string = string @meta_data = meta_data || (s.meta_data.dup unless (string.meta_data.nil? rescue true)) || {} end def to_es (@meta_data.filled? && Engine.can_enrich_output?) ? to_tag : @string end alias_method :to_s, :to_es private def to_tag keys = [:key, :value, :locale, :derivative_key] data = @meta_data.reject{|k, v| !keys.include?(k.to_sym)} tag = :i18n attrs = data.collect{|k, v| "data-#{k}=\"#{::ERB::Util.html_escape v}\""}.join " " value = @string "<#{tag} #{attrs}>#{value}</#{tag}>" end end end end end EnrichedString = Rich::I18n::Core::EnrichedString
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rich_i18n-1.2.0 | lib/rich/i18n/core/enriched_string.rb |