class Rouge::Rails::TemplateHandler
Attributes
template[RW]
Public Class Methods
call(template)
click to toggle source
# File lib/rouge/rails/template_handler.rb, line 3 def self.call(template) new(template).call end
erb_handler()
click to toggle source
# File lib/rouge/rails/template_handler.rb, line 45 def self.erb_handler @erb_handler ||= ActionView::Template.handler_for_extension(:erb) end
new(template)
click to toggle source
# File lib/rouge/rails/template_handler.rb, line 9 def initialize(template) @template = template end
Public Instance Methods
call()
click to toggle source
# File lib/rouge/rails/template_handler.rb, line 13 def call %{ lexer = #{lexer} formatter = Rouge::Formatters::HTML.new(css_class: "#{colorscheme}") formatter.format(lexer.lex(#{source})).html_safe } end
colorscheme()
click to toggle source
# File lib/rouge/rails/template_handler.rb, line 29 def colorscheme if template.locals.include?("colorscheme") "highlight \#{colorscheme}" else "highlight #{Rouge::Rails.configuration.default_colorscheme}" end end
default_lexer()
click to toggle source
# File lib/rouge/rails/template_handler.rb, line 41 def default_lexer "Rouge::Lexers::PlainText" end
erb_handler()
click to toggle source
# File lib/rouge/rails/template_handler.rb, line 49 def erb_handler self.class.erb_handler end
lexer()
click to toggle source
# File lib/rouge/rails/template_handler.rb, line 21 def lexer if template.locals.include?("language") "Rouge::Lexer.find(language) || #{default_lexer}" else default_lexer end end
source()
click to toggle source
# File lib/rouge/rails/template_handler.rb, line 37 def source "begin; #{erb_handler.call(template)} end" end