Class: ActionView::SyntaxErrorInTemplate

Inherits:
TemplateError
  • Object
show all
Defined in:
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.



233
234
235
236
# File 'lib/action_view/template/error.rb', line 233

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

Instance Method Details

#annotated_source_codeObject



244
245
246
247
248
249
# File 'lib/action_view/template/error.rb', line 244

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

#messageObject



238
239
240
241
242
# File 'lib/action_view/template/error.rb', line 238

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