Class: ActionView::SyntaxErrorInTemplate

Inherits:
TemplateError
  • Object
show all
Defined in:
actionview/lib/action_view/template/error.rb

Overview

:nodoc

Instance Method Summary collapse

Constructor Details

#initialize(template, offending_code_string) ⇒ SyntaxErrorInTemplate

Returns a new instance of SyntaxErrorInTemplate.



138
139
140
141
# File 'actionview/lib/action_view/template/error.rb', line 138

def initialize(template, offending_code_string)
  @offending_code_string = offending_code_string
  super(template)
end

Instance Method Details

#annotated_source_codeObject



149
150
151
152
153
154
# File 'actionview/lib/action_view/template/error.rb', line 149

def annotated_source_code
  @offending_code_string.split("\n").map.with_index(1) { |line, index|
    indentation = " " * 4
    "#{index}:#{indentation}#{line}"
  }
end

#messageObject



143
144
145
146
147
# File 'actionview/lib/action_view/template/error.rb', line 143

def message
  <<~MESSAGE
    Encountered a syntax error while rendering template: check #{@offending_code_string}
  MESSAGE
end