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