Class: HamlLint::Adapter::Haml4
- Inherits:
-
HamlLint::Adapter
- Object
- HamlLint::Adapter
- HamlLint::Adapter::Haml4
- Extended by:
- Forwardable
- Defined in:
- lib/haml_lint/adapter/haml_4.rb
Overview
Adapts the Haml::Parser from Haml 4 for use in HamlLint :reek:UncommunicativeModuleName
Instance Method Summary collapse
-
#initialize(source, options = Haml::Options.new) ⇒ Haml4
constructor
Parses the specified Haml code into an abstract syntax tree.
- #precompile ⇒ Object
Methods inherited from HamlLint::Adapter
Constructor Details
#initialize(source, options = Haml::Options.new) ⇒ Haml4
Parses the specified Haml code into an abstract syntax tree
20 21 22 23 |
# File 'lib/haml_lint/adapter/haml_4.rb', line 20 def initialize(source, = Haml::Options.new) @source = source @parser = Haml::Parser.new(source, ) end |
Instance Method Details
#precompile ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/haml_lint/adapter/haml_4.rb', line 25 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 |