Class: RailsErbCheck::Checker
- Inherits:
-
Object
- Object
- RailsErbCheck::Checker
- Defined in:
- lib/rails-erb-lint/helpers/rails_erb_check.rb
Constant Summary collapse
- CHECKER =
if defined?(ActionView::Template::Handlers::ERB::Erubi) ->(erb) { eval ActionView::Template::Handlers::ERB::Erubi.new(erb).src } else ->(erb) { ActionView::Template::Handlers::Erubis.new(erb).result } end
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
-
#initialize(erb_path) ⇒ Checker
constructor
A new instance of Checker.
- #valid_syntax? ⇒ Boolean
Constructor Details
#initialize(erb_path) ⇒ Checker
Returns a new instance of Checker.
14 15 16 |
# File 'lib/rails-erb-lint/helpers/rails_erb_check.rb', line 14 def initialize(erb_path) @erb = File.read(erb_path) end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
12 13 14 |
# File 'lib/rails-erb-lint/helpers/rails_erb_check.rb', line 12 def error @error end |
Instance Method Details
#valid_syntax? ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails-erb-lint/helpers/rails_erb_check.rb', line 18 def valid_syntax? begin CHECKER.call(@erb) rescue SyntaxError => e @error = e return false rescue Exception return true end end |