Class: Locomotive::Steam::Liquid::Drops::SectionEditorSettingData

Inherits:
Liquid::Drop
  • Object
show all
Defined in:
lib/locomotive/steam/liquid/drops/section_editor_setting_data.rb

Overview

Required to allow the sync between the Locomotive editor and the string/text inputs of a section and section block

Instance Method Summary collapse

Constructor Details

#initialize(section) ⇒ SectionEditorSettingData

Returns a new instance of SectionEditorSettingData.



10
11
12
# File 'lib/locomotive/steam/liquid/drops/section_editor_setting_data.rb', line 10

def initialize(section)
  @section = section
end

Instance Method Details

#liquid_method_missing(meth) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/locomotive/steam/liquid/drops/section_editor_setting_data.rb', line 14

def liquid_method_missing(meth)
  block   = nil
  prefix  = "section-#{@context['section'].id}"
  matches = (@context['forloop.name'] || '').match(SECTIONS_BLOCK_FORLOOP_REGEXP)

  # are we inside a block?
  if matches && variable_name = matches[:name]
    block = @context[variable_name]
    prefix += "-block.#{block.id}"
  end

  # only string and text inputs can synced
  if is_text?(meth.to_s, block)
    %( data-locomotive-editor-setting="#{prefix}.#{meth}")
  else
    ''
  end
end