ERB::Compiler::PercentScanner (Class)

In: libraries/erb.rb
Parent: Scanner

Methods

scan  

Public Instance methods

[Source]

     # File libraries/erb.rb, line 190
190:         def scan
191:           new_line = true
192:           stag_reg = /(.*?)(<%%|<%=|<%#|<%|\n|\z)/
193:           etag_reg = /(.*?)(%%>|%>|\n|\z)/
194:           scanner = StringScanner.new(@src)
195:           while ! scanner.eos?
196:             if new_line && @stag.nil?
197:               if scanner.scan(/%%/)
198:                 yield('%')
199:                 new_line = false
200:                 next
201:               elsif scanner.scan(/%/)
202:                 yield(PercentLine.new(scanner.scan(/.*?(\n|\z)/).chomp))
203:                 next
204:               end
205:             end
206:             scanner.scan(@stag ? etag_reg : stag_reg)
207:             text = scanner[1]
208:             elem = scanner[2]
209:             yield(text) unless text.empty?
210:             yield(elem) unless elem.empty?
211:             new_line = (elem == "\n")
212:           end
213:         end

[Validate]