Sha256: c8da432d3fb28a15dd0a36ae2c7e1d7eec09cbeb23e7e9130e911c27e2ae7ce4
Contents?: true
Size: 854 Bytes
Versions: 2
Compression:
Stored size: 854 Bytes
Contents
module SoMeta module Helper def so_meta(name, scope = nil) interpolation_data = instance_variable_get("@so_meta_#{name}_interpolation") || {} request_key = "so_meta.#{controller_path.gsub(/\//, "_")}.#{action_name}" if scope.present? begin return I18n.translate!("#{request_key}.#{scope}.#{name}", interpolation_data) rescue I18n::MissingTranslationData nil end end t("#{request_key}.#{name}", interpolation_data.merge(default: t("so_meta.defaults.#{name}"))) end def so_meta_interpolation(name, hash) variable_name = "@so_meta_#{name}_interpolation" interpolation = instance_variable_get(variable_name) || {} hash.transform_values! { |v| html_escape(v) } instance_variable_set(variable_name, interpolation.merge(hash)) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
so_meta-0.11 | lib/so_meta/helper.rb |
so_meta-0.10 | lib/so_meta/helper.rb |