lib/rouge/lexers/erb.rb in rouge-0.1.2 vs lib/rouge/lexers/erb.rb in rouge-0.2.0
- old
+ new
@@ -1,31 +1,25 @@
module Rouge
module Lexers
- class ERB < RegexLexer
+ class ERB < TemplateLexer
tag 'erb'
aliases 'eruby', 'rhtml'
filenames '*.erb', '*.erubis', '*.rhtml', '*.eruby'
def self.analyze_text(text)
return 0.4 if text =~ /<%.*%>/
end
def initialize(opts={})
- @parent = opts.delete(:parent) || 'html'
- if @parent.is_a? String
- lexer_class = Lexer.find(@parent)
- @parent = lexer_class.new(opts)
- end
-
@ruby_lexer = Ruby.new(opts)
super(opts)
end
start do
- @parent.reset!
+ parent.reset!
@ruby_lexer.reset!
end
open = /<%%|<%=|<%#|<%-|<%/
close = /%%>|-%>|%>/
@@ -34,10 +28,10 @@
rule /<%#/, 'Comment', :comment
rule open, 'Comment.Preproc', :ruby
rule /.+?(?=#{open})|.+/m do
- delegate @parent
+ delegate parent
end
end
state :comment do
rule close, 'Comment', :pop!