Class: HamlLint::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/haml_lint/parser.rb

Overview

Parses a HAML document for inspection by linters.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(haml_or_filename, options = {}) ⇒ Parser

Creates a parser containing the parse tree of a HAML document.

Parameters:

  • haml_or_filename (String)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • 'skip_frontmatter' (true, false)

    Whether to skip frontmatter included by frameworks such as Middleman or Jekyll


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/haml_lint/parser.rb', line 14

def initialize(haml_or_filename, options = {})
  if File.exist?(haml_or_filename)
    build_from_file(haml_or_filename)
  else
    build_from_string(haml_or_filename)
  end

  process_options(options)

  build_parse_tree
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents


6
7
8
# File 'lib/haml_lint/parser.rb', line 6

def contents
  @contents
end

#filenameObject (readonly)

Returns the value of attribute filename


6
7
8
# File 'lib/haml_lint/parser.rb', line 6

def filename
  @filename
end

#linesObject (readonly)

Returns the value of attribute lines


6
7
8
# File 'lib/haml_lint/parser.rb', line 6

def lines
  @lines
end

#treeObject (readonly)

Returns the value of attribute tree


6
7
8
# File 'lib/haml_lint/parser.rb', line 6

def tree
  @tree
end