Exception: Mustache::Template::UnclosedSection

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/mustache/template.rb

Overview

An UnclosedSection error is thrown when a section } is not closed.

For example:

{{# open }} blah {{/ close }}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, matching_line, unclosed_section) ⇒ UnclosedSection

Report the line number of the offending unclosed section.



21
22
23
24
25
26
27
28
29
30
# File 'lib/mustache/template.rb', line 21

def initialize(source, matching_line, unclosed_section)
  num = 0

  source.split("\n").each_with_index do |line, i|
    num = i + 1
    break if line.strip == matching_line.strip
  end

  @message = "line #{num}: ##{unclosed_section.strip} is not closed"
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



18
19
20
# File 'lib/mustache/template.rb', line 18

def message
  @message
end