Class: Locomotive::Steam::Liquid::Tags::SectionsDropzone

Inherits:
Liquid::Tag
  • Object
show all
Includes:
Concerns::Section
Defined in:
lib/locomotive/steam/liquid/tags/sections_dropzone.rb

Instance Method Summary collapse

Instance Method Details

#parse(tokens) ⇒ Object



11
12
13
# File 'lib/locomotive/steam/liquid/tags/sections_dropzone.rb', line 11

def parse(tokens)
  notify_on_parsing('_sections_dropzone_', is_dropzone: true)
end

#render(context) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/locomotive/steam/liquid/tags/sections_dropzone.rb', line 15

def render(context)
  sections_dropzone_content = context['page']&.sections_dropzone_content || []

  html = sections_dropzone_content.each_with_index.map do |content, index|
    # find the liquid source of the section
    section = find_section(context, content['type'])

    next if section.nil? # the section doesn't exist anymore?

    # assign a new dom_id to the section if it doesn't have one
    content['id'] = "dropzone-#{index}"

    # parse the template of the section
    template = build_template(section)

    render_section(context, template, section, content)
  end.join

  %(<div class="locomotive-sections">#{html}</div>)
end