Class: Rapid::Template::Pulling::Forgiving

Inherits:
Explicit show all
Defined in:
lib/rapid/template/pulling/forgiving.rb

Instance Attribute Summary

Attributes inherited from Explicit

#content, #previous_content

Attributes inherited from Base

#previous_content, #result

Instance Method Summary collapse

Methods inherited from Explicit

#empty!, #index, #initialize, #match!, #move!, #raise_not_matching, #starts_with, #starts_with?

Methods inherited from Base

#content, #empty!, #index, #initialize, #key?, #match!, #move!, #raise_not_matching, #starts_with, #starts_with?, #to_hash

Constructor Details

This class inherits a constructor from Rapid::Template::Pulling::Explicit

Instance Method Details

#match(content) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rapid/template/pulling/forgiving.rb', line 7

def match content
  result, a, b = super content
  return result, a, b if result
  
  if @content =~ starts_with_newline_regex
    len = $1.length
    result, a, b = internal_match $', content
    a += len
    return result, a, b
    
  elsif content =~ starts_with_newline_regex
    len = $1.length
    result, a, b = internal_match @content, $'
    b += len
    return result, a, b
    
  else
    return result, a, b
  end
end