# ERB::Compiler::ExplicitScanner (Class)

In: | erb.rb
Parent: | Scanner

## Methods

scan

## Public Instance methods

scan() {|'<%'| ...}

[Source]

    # File erb.rb, line 218
            def scan
              new_line = true
              stag_reg = /(.*?)(<%%|<%=|<%#|<%-|<%|\n|\z)/
              etag_reg = /(.*?)(%%>|-%>|%>|\n|\z)/
              scanner = StringScanner.new(@src)
              while ! scanner.eos?
                if new_line && @stag.nil? && scanner.scan(/[ \t]*<%-/)
                  yield('<%')
                  new_line = false
                  next
                end
                scanner.scan(@stag ? etag_reg : stag_reg)
                text = scanner[1]
                elem = scanner[2]
                new_line = (elem == "\n")
                yield(text) unless text.empty?
                if elem == '-%>'
                  yield('%>')
                  if scanner.scan(/(\n|\z)/)
                    yield(:cr)
                    new_line = true
                  end
                elsif elem == '<%-'
                  yield('<%')
                else
                  yield(elem) unless elem.empty?
                end
              end
            end

[Validate]