Skip to content

Commit

Permalink
Code simplification in scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Collins committed Jun 29, 2011
1 parent 634cf10 commit 2b66d02
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,27 @@ def process_templates
type = f.match(/.*\.(erb|haml|rhtml)$/)[1].to_sym
type = :erb if type == :rhtml
name = template_path_to_name f
text = File.read f

begin
if type == :erb
if tracker.config[:escape_html]
type = :erubis
if OPTIONS[:rails3]
src = RailsXSSErubis.new(File.read(f)).src
src = RailsXSSErubis.new(text).src
else
src = ErubisEscape.new(File.read(f)).src
src = ErubisEscape.new(text).src
end
elsif tracker.config[:erubis]
type = :erubis
src = ScannerErubis.new(File.read(f)).src
src = ScannerErubis.new(text).src
else
src = ERB.new(File.read(f), nil, "-").src
src = ERB.new(text, nil, "-").src
end
parsed = RubyParser.new.parse src
elsif type == :haml
src = Haml::Engine.new(File.read(f),
initialize_haml unless @initialized_haml
src = Haml::Engine.new(text,
:escape_html => !!tracker.config[:escape_html]).precompiled
parsed = RubyParser.new.parse src
else
Expand Down

0 comments on commit 2b66d02

Please sign in to comment.