lib/opulent/parser/node.rb in opulent-1.4.0 vs lib/opulent/parser/node.rb in opulent-1.4.1

- old
+ new

@@ -72,13 +72,13 @@ end # Add the current node to the root root(current_node, indent) - if current_node[@options][:self_enclosing] && current_node[@children].any? - error :self_enclosing_children, line - end + # if current_node[@options][:self_enclosing] && current_node[@children].any? + # error :self_enclosing_children, line + # end # Create a clone of the definition model. Cloning the options is also # necessary because it's a shallow copy if !@inside_definition && @definitions.keys.include?(node_name) parent[@children] << process_definition(node_name, current_node) @@ -97,37 +97,42 @@ def process_definition(node_name, call_context) model = @definitions[node_name].clone model[@options] = {}.merge model[@options] model[@options][:call] = call_context - # Recursively map each child node with its definition - model[@children].map! do |child| - if @definitions.keys.include? child[@value] - process_definition child[@value], child + # Recursively map each child nodes to their definitions + # for the initial call node children and for the model + # children + process_definition_child model[@options][:call] + process_definition_child model + + return model + end + + def process_definition_child(node) + node[@children].map! do |child| + if child[@type] == :node + if @definitions.keys.include? child[@value] + process_definition child[@value], child + else + process_definition_child child if child[@children] + child + end else child end end - - return model end # Helper method to create an array of values when an attribute is set # multiple times. This happens unless the key is id, which is unique # # @param atts [Hash] Current node attributes hash # @param key [Symbol] Attribute name # @param value [String] Attribute value # def add_attribute(atts, key, value) - # Check whether the attribute value needs to be evaluated or not - value[@options][:evaluate] = if value[@value] =~ Settings::EvaluationCheck - value[@value] =~ Settings::InterpolationCheck ? true : false - else - true - end - # Check for unique key and arrays of attributes if key == :class # If the key is already associated to an array, add the value to the # array, otherwise, create a new array or set it if atts[key] @@ -227,10 +232,10 @@ add_attribute(parent, argument, value) else error :assignments_colon end else - parent[argument] = [:expression, "nil", {evaluate: true, escaped: false}] unless parent[argument] + parent[argument] = [:expression, "nil", {escaped: false}] unless parent[argument] end # If our attributes are wrapped, we allow method calls without # paranthesis, ruby style, therefore we need a terminator to signify # the expression end. If they are not wrapped (inline), we require