Class: DocumentRenderer::Part

Inherits:
Object
  • Object
show all
Defined in:
lib/document_renderer/part.rb

Constant Summary collapse

PART_RE =
/{{[^}]+}}/.freeze

Class Method Summary collapse

Class Method Details

.call(content, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/document_renderer/part.rb', line 8

def call(content, options)
  @excludes = options[:excludes] || []
  content.gsub(PART_RE) do |placeholder|
    next unless placeholder
    next unless (part = options[:parts_index][placeholder])
    next unless (subpart = part[:content])
    next unless should_render?(part, omit_optional: !options[:with_optional])

    call subpart.to_s, options
  end
end