Method: WebConsole::View#render_javascript

Defined in:
lib/web_console/view.rb

#render_javascript(template) ⇒ Object

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.



23
24
25
26
27
# File 'lib/web_console/view.rb', line 23

def render_javascript(template)
  assign(template: template)
  assign(nonce: @env["action_dispatch.content_security_policy_nonce"])
  render(template: template, layout: "layouts/javascript")
end