Class: SlimLint::Document
- Inherits:
-
Object
- Object
- SlimLint::Document
- 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
-
#config ⇒ SlimLint::Configuration
readonly
Configuration used to parse template.
-
#file ⇒ String
readonly
Slim template file path.
-
#sexp ⇒ SlimLint::Sexp
readonly
Sexpression representing the parsed document.
-
#source ⇒ String
readonly
Original source code.
-
#source_lines ⇒ Array<String>
readonly
Original source code as an array of lines.
Instance Method Summary collapse
-
#initialize(source, options) ⇒ Document
constructor
Parses the specified Slim code into a Document.
Constructor Details
#initialize(source, options) ⇒ Document
Parses the specified Slim code into a SlimLint::Document.
41 42 43 44 45 46 |
# File 'lib/slim_lint/document.rb', line 41 def initialize(source, ) @config = [:config] @file = .fetch(:file, nil) process_source(source) end |
Instance Attribute Details
#config ⇒ SlimLint::Configuration (readonly)
Returns Configuration used to parse template.
21 22 23 |
# File 'lib/slim_lint/document.rb', line 21 def config @config end |
#file ⇒ String (readonly)
Returns Slim template file path.
24 25 26 |
# File 'lib/slim_lint/document.rb', line 24 def file @file end |
#sexp ⇒ SlimLint::Sexp (readonly)
Returns Sexpression representing the parsed document.
27 28 29 |
# File 'lib/slim_lint/document.rb', line 27 def sexp @sexp end |
#source ⇒ String (readonly)
Returns original source code.
30 31 32 |
# File 'lib/slim_lint/document.rb', line 30 def source @source end |
#source_lines ⇒ Array<String> (readonly)
Returns original source code as an array of lines.
33 34 35 |
# File 'lib/slim_lint/document.rb', line 33 def source_lines @source_lines end |