Sha256: 7b3f5638c5e5872f7869bb07f34566fc518542ce0dd4bd221b9ee0dfdda0fb48

Contents?: true

Size: 1.86 KB

Versions: 99

Compression:

Stored size: 1.86 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

#--
# Copyright 2004 by Jim Weirich (jim@weirichhouse.org).
# All rights reserved.

# Permission is granted for use, copying, modification, distribution,
# and distribution of modified versions of this work as long as the
# above copyright notice is included.
#++

require 'builder/xmlmarkup'

module Builder

  # Create a series of SAX-like XML events (e.g. start_tag, end_tag)
  # from the markup code.  XmlEvent objects are used in a way similar
  # to XmlMarkup objects, except that a series of events are generated
  # and passed to a handler rather than generating character-based
  # markup.
  #
  # Usage:
  #   xe = Builder::XmlEvents.new(hander)
  #   xe.title("HI")    # Sends start_tag/end_tag/text messages to the handler.
  #
  # Indentation may also be selected by providing value for the
  # indentation size and initial indentation level.
  #
  #   xe = Builder::XmlEvents.new(handler, indent_size, initial_indent_level)
  #
  # == XML Event Handler
  #
  # The handler object must expect the following events.
  #
  # [<tt>start_tag(tag, attrs)</tt>]
  #     Announces that a new tag has been found.  +tag+ is the name of
  #     the tag and +attrs+ is a hash of attributes for the tag.
  #
  # [<tt>end_tag(tag)</tt>]
  #     Announces that an end tag for +tag+ has been found.
  #
  # [<tt>text(text)</tt>]
  #     Announces that a string of characters (+text+) has been found.
  #     A series of characters may be broken up into more than one
  #     +text+ call, so the client cannot assume that a single
  #     callback contains all the text data.
  #
  class XmlEvents < XmlMarkup
    def text!(text)
      @target.text(text)
    end

    def _start_tag(sym, attrs, end_too=false)
      @target.start_tag(sym, attrs)
      _end_tag(sym) if end_too
    end

    def _end_tag(sym)
      @target.end_tag(sym)
    end
  end

end

Version data entries

99 entries across 61 versions & 21 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/builder-3.3.0/lib/builder/xmlevents.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/builder-3.3.0/lib/builder/xmlevents.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/builder-3.3.0/lib/builder/xmlevents.rb
builder-3.3.0 lib/builder/xmlevents.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
ric-0.14.2 vendor/bundle/ruby/2.7.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
ric-0.14.1 vendor/bundle/ruby/2.7.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/builder-3.2.4/lib/builder/xmlevents.rb
ric-0.14.0 vendor/bundle/ruby/2.7.0/gems/builder-3.2.4/lib/builder/xmlevents.rb