class DocTemplate::Tags::ExpandTag
Constants
- BREAK_TAG_NAME
- TAG_NAME
- TEMPLATES
Public Instance Methods
parse_table(table)
click to toggle source
# File lib/doc_template/tags/expand_tag.rb, line 11 def parse_table(table) params = { subject: (@opts[:metadata].try(:[], 'subject').presence || 'ela').downcase } params[:content], params[:content_hidden] = fetch_content table parsed_template = parse_template params, template_name(@opts) @content = parse_nested(parsed_template, @opts) replace_tag table end
Private Instance Methods
fetch_content(node)
click to toggle source
# File lib/doc_template/tags/expand_tag.rb, line 22 def fetch_content(node) broken = false content_visible = [] content_hidden = [] # iterates over all child nodes looking for break tag node.at_xpath('.//tr[2]/td').children.each do |child| (broken = true) && next if child.text.index("[#{BREAK_TAG_NAME}]") child.remove_attribute('class') child.children.each { |x| x.remove_attribute('class') } broken ? content_hidden.push(child) : content_visible.push(child) end [content_visible.map(&:to_html).join, content_hidden.map(&:to_html).join] end