Sha256: 099d6f30574d21b86dee5110363f8796b32e10bcfb04ece8e0a6eef12f7f4686
Contents?: true
Size: 1.12 KB
Versions: 31
Compression:
Stored size: 1.12 KB
Contents
# @Opulent module Opulent # @Nodes module Nodes # @Define # # Define a custom HTML element # class Define < Node # Node evaluation method which goes through all the child nodes and # evaluates them using their own eval method # def evaluate(context, blocks = {}) yields = @yields.clone @children.map do |child| evaluated_child = child.evaluate context # Check to see if the child element being mapped is one of the yield # node parent pointers if yields.include? child yields.delete child # We need to replace the yield nodes with the matching named block # in order to map the yield node correctly evaluated_child.children.map! do |subchild| if subchild.is_a?(Yield) && blocks[subchild.name] blocks[subchild.name] else subchild end end evaluated_child.children.compact! evaluated_child.children.flatten! end evaluated_child end end end end end
Version data entries
31 entries across 31 versions & 1 rubygems