Sha256: 5dab4f2c951b79f3656f05eb805bf0f3f9494373ea550d6d62457c8725b066a2

Contents?: true

Size: 1.04 KB

Versions: 12

Compression:

Stored size: 1.04 KB

Contents

module RailsConnector

  module CmsTagHelper

    # A wrapper for [http://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-content_tag]
    # If {cms_editor_mode?} returns true, it also renders additional data attributes, which are needed for inline editing.
    # @param tag_name [String, Symbol] Name of the html tag (e.g. +:h1+ or +:div+).
    # @param obj [Obj] A {Obj} from which attribute is read.
    # @param attribute [String, Symbol] Which attribute should be render.
    # @param options [Hash] Additional options, which are passed to +content_tag+.
    def cms_tag(tag_name, obj, attribute, options = {})
      options = options.merge({
        'data-ip-field-id' => obj.id,
        'data-ip-field-obj-class' => obj.obj_class,
        'data-ip-field-name' => attribute,
        'data-ip-field-type' => obj.type_of_attribute(attribute.to_s),
      }) if cms_editor_mode?

      content_tag(tag_name, display_value(obj[attribute]), options)
    end

    def cms_editor_mode?
      !Workspace.current.published?
    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.8.3.73.75172665 app/helpers/rails_connector/cms_tag_helper.rb
infopark_cloud_connector-6.8.3.2.153416031 app/helpers/rails_connector/cms_tag_helper.rb
infopark_cloud_connector-6.8.3.67.110847540 app/helpers/rails_connector/cms_tag_helper.rb
infopark_cloud_connector-6.8.3.1.23895778 app/helpers/rails_connector/cms_tag_helper.rb
infopark_cloud_connector-6.8.2.36.82613853 app/helpers/rails_connector/cms_tag_helper.rb
infopark_cloud_connector-6.8.2.7.128454143 app/helpers/rails_connector/cms_tag_helper.rb
infopark_cloud_connector-6.8.1.26.236500544 app/helpers/rails_connector/cms_tag_helper.rb
infopark_cloud_connector-6.8.1 app/helpers/rails_connector/cms_tag_helper.rb
infopark_cloud_connector-6.8.0.539.93842523 app/helpers/rails_connector/cms_tag_helper.rb
infopark_cloud_connector-6.8.0.529.114081979 app/helpers/rails_connector/cms_tag_helper.rb
infopark_cloud_connector-6.8.0.518.30999728 app/helpers/rails_connector/cms_tag_helper.rb
infopark_cloud_connector-6.8.0.515.34928522 app/helpers/rails_connector/cms_tag_helper.rb