Class: SlimLint::Engine
- Inherits:
-
Temple::Engine
- Object
- Temple::Engine
- SlimLint::Engine
- Defined in:
- lib/slim_lint/engine.rb
Overview
Temple engine used to generate a Sexp parse tree for use by linters.
We omit a lot of the filters that are in Slim::Engine because they result in information potentially being removed from the parse tree (since some Sexp abstractions are optimized/removed or otherwise transformed). In order for linters to be useful, they need to operate on the original parse tree.
The other key task this engine accomplishes is converting the Array-based S-expressions into Sexp objects, which have a number of helper methods that makes working with them easier. It also annotates these Sexp objects with line numbers so it’s easy to cross reference with the original source code.
Instance Method Summary collapse
-
#parse(source) ⇒ SlimLint::Sexp
Parses the given source code into a Sexp.
Instance Method Details
#parse(source) ⇒ SlimLint::Sexp
Parses the given source code into a Sexp.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/slim_lint/engine.rb', line 33 def parse(source) call(source) rescue ::Slim::Parser::SyntaxError => e # Convert to our own exception type to isolate from upstream changes error = SlimLint::Exceptions::ParseError.new(e.error, e.file, e.line, e.lineno, e.column) raise error end |