Module: Ritsu::TemplatePolicies::FlexibleBlockMatchingAndCreateMissingBlocksButIgnoreUserText

Includes:
FlexibleBlockMatching
Defined in:
lib/ritsu/template_policies.rb

Instance Method Summary collapse

Methods included from FlexibleBlockMatching

#match_child_blocks

Instance Method Details

#update_block(block, options = {}) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/ritsu/template_policies.rb', line 79

def update_block(block, options={})
  matching_child_blocks = match_child_blocks(block)
  
  block.contents.clear
  contents.each do |content|
    if content.kind_of?(Template)
      if matching_child_blocks[content].nil?
        block.contents << content.create_block(options)
      else
        matching = matching_child_blocks[content]
        content.update_block(matching)
        block.contents << matching
      end
    else
      block.contents << content
    end
  end
end