Class: PackwerkHaml::Parser

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
Packwerk::FileParser
Defined in:
lib/packwerk_haml/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(haml_compiler: ::Haml::Engine.new, ruby_parser: ::Packwerk::Parsers::Ruby.new) ⇒ Parser

Returns a new instance of Parser.



14
15
16
17
# File 'lib/packwerk_haml/parser.rb', line 14

def initialize(haml_compiler: ::Haml::Engine.new, ruby_parser: ::Packwerk::Parsers::Ruby.new)
  @haml_compiler = haml_compiler
  @ruby_parser = ruby_parser
end

Instance Method Details

#call(io:, file_path: "<unknown>") ⇒ Object



20
21
22
# File 'lib/packwerk_haml/parser.rb', line 20

def call(io:, file_path: "<unknown>")
  parse_template(io.read, file_path: file_path)
end

#match?(path:) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/packwerk_haml/parser.rb', line 25

def match?(path:)
  File.extname(path) == ".haml"
end