Class: DocTemplate::Tags::ColumnsTag

Inherits:
BlockTag show all
Includes:
ERB::Util
Defined in:
lib/doc_template/tags/columns_tag.rb

Constant Summary collapse

ALIGNMENT_RE =
/^align-right\s/i.freeze
SPLIT_SYMBOL =
';'
TAG_NAME =
'columns'
TEMPLATE =
'columns.html.erb'

Constants inherited from BlockTag

BlockTag::END_VALUE

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 inherited from BlockTag

#block_nodes, #no_end_tag_for

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
# File 'lib/doc_template/tags/columns_tag.rb', line 13

def parse(node, opts = {})
  @opts = opts
  @images = []
  @tags = []

  data = fetch_content node

  rows = substitute_images(data).map do |row|
    row.map do |td|
      td = substitute_tags td
      handle_alignment_for td
    end
  end

  @content = parse_template({ rows: rows }, TEMPLATE) if rows.any?
  replace_tag node
  self
end