class DevelopmentModePlugin
Public Instance Methods
after_response(current_response, _)
click to toggle source
# File lib/hypernova/plugins/development_mode_plugin.rb, line 4 def after_response(current_response, _) current_response.each do |name, result| current_response[name] = result.merge({ "html" => render(name, result) }) if result["error"] end end
Private Instance Methods
html_escape(string)
click to toggle source
# File lib/hypernova/plugins/development_mode_plugin.rb, line 37 def html_escape(string) ::ERB::Util.html_escape(string) end
render(name, result)
click to toggle source
# File lib/hypernova/plugins/development_mode_plugin.rb, line 12 def render(name, result) <<-HTML <div style="background-color: #ff5a5f; color: #fff; padding: 12px;"> <p style="margin: 0"> <strong>Development Warning!</strong> The <code>#{html_escape(name)}</code> component failed to render with Hypernova. Error stack: </p> #{ render_stack_trace(stack_trace(result)) } </div> #{result["html"]} HTML end
render_stack_trace(trace)
click to toggle source
# File lib/hypernova/plugins/development_mode_plugin.rb, line 25 def render_stack_trace(trace) # Put trace that was split in Hypernova back together, verbatim. Sometimes # splitting babel errors makes them more confusing. # https://github.com/airbnb/hypernova/blob/master/src/utils/BatchManager.js text = html_escape(trace.join("\n ")) <<-HTML <div style="white-space: pre-wrap; font-family: monospace; font-size: .95em;" >#{text}</div> HTML end
stack_trace(result)
click to toggle source
# File lib/hypernova/plugins/development_mode_plugin.rb, line 41 def stack_trace(result) result["error"]["stack"] || [] end