24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/erb/stripper.rb', line 24
def to_ruby(source)
result = ''
= false
scanner = ERB::Compiler.new(nil).make_scanner(source)
scanner.scan do |token|
= true if token == '<%#'
if scanner.stag.nil?
result << to_whitespace(token)
scanner.stag = token if ['<%', '<%%', '<%-', '<%=', '<%%=', '<%#'].include?(token.strip)
elsif ['%>', '%%>', '-%>'].include?(token.strip)
result << to_whitespace(token.gsub(/>/, ';'))
scanner.stag = nil
else
result << ( ? to_whitespace(token) : token)
= false
end
end
result
end
|