Class: DocTemplate::Tags::ActivityMetadataSectionTag

Inherits:
BaseTag
  • Object
show all
Includes:
Helpers, ERB::Util
Defined in:
lib/doc_template/tags/activity_metadata_section_tag.rb

Constant Summary collapse

TAG_NAME =
'activity-metadata-section'
TEMPLATES =
{ default: 'group-math.html.erb',
gdoc: 'gdoc/group-math.html.erb' }.freeze

Constants included from Helpers

Helpers::ICON_PATH

Constants inherited from BaseTag

BaseTag::SOFT_RETURN_RE, BaseTag::UNICODE_SPACES_RE

Instance Attribute Summary

Attributes inherited from BaseTag

#anchor, #content

Instance Method Summary collapse

Methods included from Helpers

#materials_container, #priority_description, #priority_icon

Methods inherited from BaseTag

#before_tag, #check_tag_soft_return, #content_until_break, #content_until_materials, #ela2?, #ela6?, #gdoc?, #include_break?, #include_break_for?, #materials, parse, #parse_nested, #parse_template, #placeholder, #placeholder_id, #render, #replace_tag, #tag_data, tag_with_html_regexp, #template_name, #template_path, template_path_for

Instance Method Details

#parse(node, opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/doc_template/tags/activity_metadata_section_tag.rb', line 13

def parse(node, opts = {})
  @opts = opts
  @section = @opts[:sections].level1_by_title(@opts[:value])
  @anchor = @section.anchor
  @materials = @section.material_ids

  parse_foundational

  before_materials = ''
  if (with_materials = @section.material_ids.any?)
    before_materials = content_until_materials node
    before_materials = parse_nested before_materials.to_s, opts
  end

  content = content_until_break node
  content.scan(DocTemplate::FULL_TAG).select { |t| t.first == ActivityMetadataTypeTag::TAG_NAME }.each do |(_, a)|
    @section.add_activity opts[:activity].find_by_anchor(a)
  end
  content = parse_nested content.to_s, opts
  params = {
    before_materials: before_materials,
    # TODO: check maybe it's ok to move it somewhere else,
    # fixed at #692 bc with new section we always have some garbage before activity
    content: DocTemplate.sanitizer.strip_html(content),
    foundational_skills: opts[:foundational_skills],
    placeholder: placeholder_id,
    react_props: {
      activity: {
        title: @section.title
      },
      group: true,
      material_ids: @section.material_ids
    },
    section: @section,
    with_materials: with_materials
  }
  @content = parse_template params, template_name(opts)
  replace_tag node
  self
end