Sha256: ff6f15274174ea7d0b4638d8e9ef048f08fb84e6eb285b5c5a055dbe099301af

Contents?: true

Size: 950 Bytes

Versions: 6

Compression:

Stored size: 950 Bytes

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

        end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc9 lib/locomotive/liquid/tags/editable/short_text.rb
locomotive_cms-2.0.0.rc8 lib/locomotive/liquid/tags/editable/short_text.rb
locomotive_cms-2.0.0.rc7 lib/locomotive/liquid/tags/editable/short_text.rb
locomotive_cms-2.0.0.rc6 lib/locomotive/liquid/tags/editable/short_text.rb
locomotive_cms-2.0.0.rc5 lib/locomotive/liquid/tags/editable/short_text.rb
locomotive_cms-2.0.0.rc4 lib/locomotive/liquid/tags/editable/short_text.rb