Module: IJSRails::ActionViewHelpers

Extended by:
ActiveSupport::Concern
Defined in:
lib/ijs-rails/action_view_helpers.rb

Overview

Helper methods to include into action view.

Instance Method Summary collapse

Instance Method Details

#render_ijs(script, options = {}) ⇒ String

Render an HTML <script> tag containing the compiled script.

Parameters:

  • script (String)

    The name of the inline script to render.

  • options (Hash) (defaults to: {})

    The options to pass to the compiler.

Returns:

  • (String)

    An HTML <script> tag containing the compiled script.



15
16
17
18
19
20
21
22
# File 'lib/ijs-rails/action_view_helpers.rb', line 15

def render_ijs(script, options = {})
  tag_options = options.dup
  script_options = tag_options.slice!(:async, :defer, :nonce, :type)

  javascript_tag(tag_options) do
    IJSRails::Script.new(script, script_options).compiled.html_safe
  end
end