Sha256: c35eee2ee8ae43c75b4af6d2d27fc8c5db23598bc61f6f2b026458c8bc597893
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
module Codeqa module Checkers class CheckErb < Checker def self.check?(sourcefile) sourcefile.erb? end def self.available? engine? end def name 'erb syntax' end def hint 'There is a syntax error in the ruby code of the erb parsed file.' end # rubocop:disable RescueException,HandleExceptions def check if defined?(ActionView) ActionView::Template::Handlers::Erubis.new(erb).result else ERB.new(sourcefile.content.gsub('<%=', '<%'), nil, '-').result end rescue SyntaxError errors.add(nil, <<-EOF) #{$!.message} #{$!.backtrace.join("\n")} EOF rescue Exception true # valid syntax - just the proper setup for the template/rendering is missing end # rubocop:enable RescueException,HandleExceptions def self.engine? @@engine ||= if %w(actionview action_view).include? Codeqa.configuration.erb_engine.downcase require 'action_view' true else require 'erb' true end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
codeqa-0.3.1 | lib/codeqa/checkers/check_erb.rb |
codeqa-0.3.0 | lib/codeqa/checkers/check_erb.rb |