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.

Constant Summary collapse

FRONTMATTER_RE =
/
  # From the start of the string
  \A
  # First-capture match --- followed by optional whitespace up
  # to a newline then 0 or more chars followed by an optional newline.
  # This matches the --- and the contents of the frontmatter
  (---\s*\n.*?\n?)
  # From the start of the line
  ^
  # Second capture match --- or ... followed by optional whitespace
  # and newline. This matches the closing --- for the frontmatter.
  (---|\.\.\.)\s*$\n?
/mx

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options) ⇒ Document

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

Options Hash (options):

  • :file (String)

    file name of document that was parsed

Raises:

  • (Slim::Parser::Error)

    if there was a problem parsing the document



41
42
43
44
45
46
# File 'lib/slim_lint/document.rb', line 41

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

  process_source(source)
end

Instance Attribute Details

#configSlimLint::Configuration (readonly)



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

def config
  @config
end

#fileString (readonly)



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

def file
  @file
end

#sexpSlimLint::Sexp (readonly)



27
28
29
# File 'lib/slim_lint/document.rb', line 27

def sexp
  @sexp
end

#sourceString (readonly)



30
31
32
# File 'lib/slim_lint/document.rb', line 30

def source
  @source
end

#source_linesArray<String> (readonly)



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

def source_lines
  @source_lines
end