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.



257
258
259
260
# File 'actionview/lib/action_view/template/error.rb', line 257

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

Instance Method Details

#annotated_source_codeObject



272
273
274
275
276
277
# File 'actionview/lib/action_view/template/error.rb', line 272

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

#messageObject



262
263
264
265
266
267
268
269
270
# File 'actionview/lib/action_view/template/error.rb', line 262

def message
  if template.is_a?(Template::Inline)
    <<~MESSAGE
      Encountered a syntax error while rendering template: check #{@offending_code_string}
    MESSAGE
  else
    "Encountered a syntax error while rendering template located at: #{template.short_identifier}"
  end
end