Sha256: 5daf4e2fd78d63b74010d62ae914b6f767369732431673599fab7128d5552612

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

# frozen_string_literal: true

module IJSRails
  # Helper methods to include into action view.
  #
  module ActionViewHelpers
    extend ActiveSupport::Concern

    # Render an HTML <script> tag containing the compiled script.
    #
    # @param  script  [String] The name of the inline script to render.
    # @param  options [Hash]   The options to pass to the compiler.
    # @return         [String] An HTML <script> tag containing the compiled script.
    #
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ijs-rails-0.2.0 lib/ijs-rails/action_view_helpers.rb