class Locomotive::Steam::Liquid::Tags::Editable::Text
Protected Instance Methods
default_content?(element)
click to toggle source
# File lib/locomotive/steam/liquid/tags/editable/text.rb, line 38 def default_content?(element) element.content.blank? end
default_element_attributes()
click to toggle source
Calls superclass method
Locomotive::Steam::Liquid::Tags::Editable::Base#default_element_attributes
# File lib/locomotive/steam/liquid/tags/editable/text.rb, line 42 def default_element_attributes super.merge( content_from_default: self.render_default_content, format: attributes[:format] || 'html', rows: attributes[:rows] || 10, inline: attributes[:inline], line_break: attributes[:line_break].blank? ? true : attributes[:line_break], ) end
dom_id(context)
click to toggle source
# File lib/locomotive/steam/liquid/tags/editable/text.rb, line 52 def dom_id(context) block_name = context['block'].try(:name).try(:gsub, '/', '-') ['locomotive-editable-text', block_name, slug].compact.join('-') end
format_content(content, format, context)
click to toggle source
# File lib/locomotive/steam/liquid/tags/editable/text.rb, line 22 def format_content(content, format, context) case format when 'markdown' then markdown_service(context).to_html(content) else content end end
markdown_service(context)
click to toggle source
# File lib/locomotive/steam/liquid/tags/editable/text.rb, line 57 def markdown_service(context) context.registers[:services].markdown end
render_element(context, element)
click to toggle source
# File lib/locomotive/steam/liquid/tags/editable/text.rb, line 10 def render_element(context, element) with_inline_editing(context, element) do content = if default_content?(element) render_default_content else element.content end format_content(content, element.format, context) end end
with_inline_editing(context, element) { || ... }
click to toggle source
# File lib/locomotive/steam/liquid/tags/editable/text.rb, line 30 def with_inline_editing(context, element, &block) if editable?(context, element) %{<span class="locomotive-editable-text" id="#{dom_id(context)}" data-element-id="#{element._id}">#{yield}</span>} else yield end end