class WebConsole::Template::Context
Public Instance Methods
only_on_error_page(*args) { || ... }
click to toggle source
Execute a block only on error pages.
The error pages are special, because they are the only pages that currently require multiple bindings. We get those from exceptions.
# File lib/web_console/template.rb, line 12 def only_on_error_page(*args) yield if @env['web_console.exception'].present? end
render_inlined_string(template)
click to toggle source
Render inlined string to be used inside of JavaScript code.
The inlined string is returned as an actual JavaScript string. You don't need to wrap the result yourself.
# File lib/web_console/template.rb, line 29 def render_inlined_string(template) render(template: template, layout: 'layouts/inlined_string') end
render_javascript(template)
click to toggle source
Render JavaScript inside a script tag and a closure.
This one lets write JavaScript that will automatically get wrapped in a script tag and enclosed in a closure, so you don't have to worry for leaking globals, unless you explicitly want to.
# File lib/web_console/template.rb, line 21 def render_javascript(template) render(template: template, layout: 'layouts/javascript') end