Class: HamlLint::Adapter::Haml5
- Inherits:
-
HamlLint::Adapter
- Object
- HamlLint::Adapter
- HamlLint::Adapter::Haml5
- Defined in:
- lib/haml_lint/adapter/haml_5.rb
Overview
Adapts the Haml::Parser from Haml 5 for use in HamlLint :reek:UncommunicativeModuleName
Instance Method Summary collapse
-
#initialize(source, options = Haml::Options.new) ⇒ Haml5
constructor
Parses the specified Haml code into an abstract syntax tree.
-
#parse ⇒ Haml::Parser::ParseNode
Parses the source code into an abstract syntax tree.
- #precompile ⇒ Object
Methods inherited from HamlLint::Adapter
Constructor Details
#initialize(source, options = Haml::Options.new) ⇒ Haml5
Parses the specified Haml code into an abstract syntax tree
16 17 18 19 |
# File 'lib/haml_lint/adapter/haml_5.rb', line 16 def initialize(source, = Haml::Options.new) @source = source @parser = Haml::Parser.new() end |
Instance Method Details
#parse ⇒ Haml::Parser::ParseNode
Parses the source code into an abstract syntax tree
29 30 31 |
# File 'lib/haml_lint/adapter/haml_5.rb', line 29 def parse parser.call(source) end |
#precompile ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/haml_lint/adapter/haml_5.rb', line 33 def precompile # Haml uses the filters as part of precompilation... we don't care about those, # but without this tweak, it would fail on filters that are not loaded. real_defined = Haml::Filters.defined Haml::Filters.instance_variable_set(:@defined, Hash.new { real_defined['plain'] }) ::Haml::Engine.new(source).precompiled ensure Haml::Filters.instance_variable_set(:@defined, real_defined) end |