Sha256: 3a26201f5a0370acbd22d8a87816a1eaa431562e4d5e5cc9b0bada419f9a19d6

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

module Locomotive
  module Liquid
    module Tags
      module Editable
        class ShortText < Base

          protected

          def render_element(context, element)
            content = element.default_content? ? render_default_content(context) : element.content

            if editable?(context, element)
              %{
                <span class='editable-short-text' data-element-id='#{element.id}' data-element-index='#{element._index}'>
                  #{content}
                </span>
              }
            else
              content
            end
          end

          def document_type
            EditableShortText
          end

          def editable?(context, element)
            context.registers[:inline_editor] && (!element.fixed? || (element.fixed? && !element.from_parent?))
          end

          def default_element_attributes
            super.merge(content_from_default: self.render_default_content(nil))
          end

        end

        ::Liquid::Template.register_tag('editable_short_text', ShortText)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
locomotive_cms-2.1.4 lib/locomotive/liquid/tags/editable/short_text.rb
locomotive_cms-2.1.3 lib/locomotive/liquid/tags/editable/short_text.rb
locomotive_cms-2.1.2 lib/locomotive/liquid/tags/editable/short_text.rb
locomotive_cms-2.1.1 lib/locomotive/liquid/tags/editable/short_text.rb
locomotive_cms-2.1.0 lib/locomotive/liquid/tags/editable/short_text.rb