Sha256: b938ae64354672be12a815827b463778835911731ff545316561ed0a92baf624

Contents?: true

Size: 1.49 KB

Versions: 18

Compression:

Stored size: 1.49 KB

Contents

# @Opulent
module Opulent
  # @Parser
  class Parser
    # Match a yield with a explicit or implicit target
    #
    # yield target
    #
    # @param parent [Node] Parent node to which we append the definition
    #
    def block_yield(parent, indent)
      if accept :yield
        # Get definition name
        if(yield_name = accept_stripped(:yield_identifier))
          yield_name = yield_name.strip.to_sym
        else
          yield_name = Settings::DefaultYield
        end

        # Consume the newline from the end of the element
        error :yield unless accept(:line_feed).strip.empty?

        # Create a new node
        yield_node = [:yield, yield_name, {}, [], indent]

        parent[@children] << yield_node
      end
    end

    # Match a block with a explicit target
    #
    # block target
    #
    # @param parent [Node] Parent node to which we append the definition
    #
    def block(parent, indent)
      if accept :block
        # Get definition name
        if(block_name = accept_stripped(:yield_identifier))
          block_name = block_name.strip.to_sym
        else
          block_name = Settings::DefaultYield
        end

        # Consume the newline from the end of the element
        error :block unless accept(:line_feed).strip.empty?

        # Create a new node
        block_node = [:block, block_name, {}, [], indent]
        root block_node, indent

        parent[@children] << block_node
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
opulent-1.4.0 lib/opulent/parser/block.rb
opulent-1.3.3 lib/opulent/parser/block.rb
opulent-1.3.2 lib/opulent/parser/block.rb
opulent-1.3.1 lib/opulent/parser/block.rb
opulent-1.3.0 lib/opulent/parser/block.rb
opulent-1.2.1 lib/opulent/parser/block.rb
opulent-1.2.0 lib/opulent/parser/block.rb
opulent-1.1.9 lib/opulent/parser/block.rb
opulent-1.1.7 lib/opulent/parser/block.rb
opulent-1.1.6 lib/opulent/parser/block.rb
opulent-1.1.5 lib/opulent/parser/block.rb
opulent-1.1.0 lib/opulent/parser/block.rb
opulent-1.0.9 lib/opulent/parser/block.rb
opulent-1.0.8 lib/opulent/parser/block.rb
opulent-1.0.7 lib/opulent/parser/block.rb
opulent-1.0.4 lib/opulent/parser/block.rb
opulent-1.0.3 lib/opulent/parser/block.rb
opulent-1.0.2 lib/opulent/parser/block.rb