class HamlLint::Adapter::Haml6
Adapts the Haml::Parser from Haml
6 for use in HamlLint
:reek: UncommunicativeModuleName
Attributes
parser[R]
Public Class Methods
new(source, options = {})
click to toggle source
Parses the specified Haml
code into an abstract syntax tree
@example
HamlLint::Adapter::Haml6.new('%div')
@api public @param source [String] Haml
code to parse @param options [private Haml::Parser::ParserOptions]
# File lib/haml_lint/adapter/haml_6.rb, line 16 def initialize(source, options = {}) @source = source @parser = Haml::Parser.new(options) end
Public Instance Methods
parse()
click to toggle source
Parses the source code into an abstract syntax tree
@example
HamlLint::Adapter::Haml6.new('%div').parse
@api public @return [Haml::Parser::ParseNode] @raise [Haml::Error]
# File lib/haml_lint/adapter/haml_6.rb, line 29 def parse parser.call(source) end
precompile()
click to toggle source
# File lib/haml_lint/adapter/haml_6.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.registered Haml::Filters.instance_variable_set(:@registered, Hash.new { real_defined['plain'] }) ::Haml::Engine.new.call(source) ensure Haml::Filters.instance_variable_set(:@registered, real_defined) end