Sha256: 48ce21fabd8533040f6971f3a5aafb60b3b7b89f61900e1e626cd80f045681e4

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

Contents

module Mokio
  module FrontendHelpers
    #
    # Frontend helper methods used with Mokio::SeoTag objects
    #
    module SeoTagHelper
      def render_seo_meta_tags(model_obj)
        result = ""
        return result unless model_obj.class.has_seo_tagable_enabled?
        collection = model_obj.seo_tags
        if collection.any?
          seo_hash =  {}
          Mokio::SeoTag.seo_tags_list.map{|a| seo_hash[a[:key].to_sym] = a[:type]}
          collection.each do |el|
            result << render_seo_meta_build_tag_helper(el,seo_hash)
          end
        end
        result
      end

      private

      def render_seo_meta_build_tag_helper(el, seo_hash)
        return nil unless el.present? && seo_hash.present?
        if el.is_title?
          content_tag(:title, el.tag_value)
        else
          tag(:meta, "#{seo_hash[el.tag_key.to_sym]}" => ("#{el.tag_key}"), :content => ("#{el.tag_value}"))
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mokio-2.0.8 lib/mokio/frontend_helpers/seo_tag_helper.rb