Class: SlimLint::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/slim_lint/document.rb

Overview

Represents a parsed Slim document and its associated metadata.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options) ⇒ Document

Parses the specified Slim code into a SlimLint::Document.

Parameters:

  • source (String)

    Slim code to parse

  • options (Hash)

Options Hash (options):

  • :file (String)

    file name of document that was parsed

Raises:

  • (Slim::Parser::Error)

    if there was a problem parsing the document



33
34
35
36
37
38
# File 'lib/slim_lint/document.rb', line 33

def initialize(source, options)
  @config = options[:config]
  @file = options.fetch(:file, nil)

  process_source(source)
end

Instance Attribute Details

#configSlimLint::Configuration (readonly)

Returns Configuration used to parse template.

Returns:



7
8
9
# File 'lib/slim_lint/document.rb', line 7

def config
  @config
end

#fileString (readonly)

Returns Slim template file path.

Returns:

  • (String)

    Slim template file path



10
11
12
# File 'lib/slim_lint/document.rb', line 10

def file
  @file
end

#original_sourceString (readonly)

Returns source code before optional frontmatter removal.

Returns:

  • (String)

    source code before optional frontmatter removal



19
20
21
# File 'lib/slim_lint/document.rb', line 19

def original_source
  @original_source
end

#sexpSlimLint::Sexp (readonly)

Returns Sexpression representing the parsed document.

Returns:



13
14
15
# File 'lib/slim_lint/document.rb', line 13

def sexp
  @sexp
end

#sourceString (readonly)

Returns original source code.

Returns:

  • (String)

    original source code



16
17
18
# File 'lib/slim_lint/document.rb', line 16

def source
  @source
end

#source_linesArray<String> (readonly)

Returns original source code as an array of lines.

Returns:

  • (Array<String>)

    original source code as an array of lines



25
26
27
# File 'lib/slim_lint/document.rb', line 25

def source_lines
  @source_lines
end

#source_prefixString (readonly)

Returns source removed before linting, such as frontmatter.

Returns:

  • (String)

    source removed before linting, such as frontmatter



22
23
24
# File 'lib/slim_lint/document.rb', line 22

def source_prefix
  @source_prefix
end