Sha256: 57b9b6478957d0352a66ab4815c266f9f62d4fb603debb44900998eaa4b2c586
Contents?: true
Size: 874 Bytes
Versions: 7
Compression:
Stored size: 874 Bytes
Contents
require "ember/rails/assets/javascript" module Ember module Rails module Assets class Middleware < Struct.new(:app) def call env @status, @headers, @body = app.call(env) return [@status, @headers, @body] unless html? response = Rack::Response.new([], @status, @headers) @body.each do |fragment| response.write inject(fragment) end @body.close if @body.respond_to?(:close) response.finish end private def html? @headers["Content-Type"] =~ /html/ end def inject response key = "ASSETS" path = ActionView::Base.assets_manifest.path markup = Javascript.new(key, path).render response.gsub(%r{</head>}, "<script>#{markup}</script></head>") end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems