Sha256: a7ea843697b4381e1457a5534b6885c1c431ab2bc8c6ff10641df22e618eb6c9

Contents?: true

Size: 549 Bytes

Versions: 1

Compression:

Stored size: 549 Bytes

Contents

require 'requirejs/error'

module RequirejsHelper
  def requirejs_include_tag(tag=nil)
    html = ""
    
    if controller.requirejs_included
      raise Requirejs::MultipleIncludeError, "Only one requirejs_include_tag allowed per page."
    end
    html = <<-HTML
    <script>
      var require = #{Rails.application.config.requirejs.run_config_json};
    </script>
    #{javascript_include_tag "require"}
    HTML
    controller.requirejs_included = true

    if tag
      html << javascript_include_tag(tag)
    end
    html.html_safe
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
requirejs-rails-0.5.0 app/helpers/requirejs_helper.rb