Sha256: 934d1a1389a165bf57f34e5a8c1a809a2dee51e6868d1b979e7f1fc7235a56c6

Contents?: true

Size: 1.79 KB

Versions: 7

Compression:

Stored size: 1.79 KB

Contents

require "action_controller"
require "action_controller/metal/renderers"
require "execjs"
require "execjs-rails"
require "jquery-rails"
require "sprockets-coffee-react"
require "react-rails"
require "react/source"
require "backbone-rails"
require "underscore-string-rails"
require "sass"
require "sass-rails"
require "foundation-rails"

module Revelry
  module Core
    class Engine < ::Rails::Engine
      ROUTER_ASSET = 'revelry/router/router'

      # Require the route config to load before we load the router assets
      # (otherwise, route table is empty)
      initializer 'revelry.dependent_on_routes', after: "sprockets.environment" do
        if Rails.application.assets.respond_to?(:register_preprocessor)
          routes = Rails.root.join('config','routes.rb')
          Rails.application.assets.register_preprocessor 'application/javascript', :'revelry.dependent_on_routes' do |ctx,data|
            require routes if ctx.logical_path == ROUTER_ASSET
            data
          end
        end
      end

      # Enable controllers to respond to .props format, which returns the same
      # props that execjs uses for serverside render (as a JSON object)
      initializer "revelry.setup_props_renderer", :group => :all do |app|
        Mime::Type.register_alias "text/reactprops", :props

        ActionController.add_renderer :props do |foo, opts|
          self.response_body = render_to_string template: Revelry::Core::PropsTemplate.new('', 'path', ActionView::Template.registered_template_handler(:erb), format: Mime[:erb], virtual_path: 'path')
        end
      end

      initializer 'revelry.set_react_version', before: 'react_rails.setup_vendor' do |app|
        app.config.react.addons = true
        app.config.react.variant = (::Rails.env.production? ? :production : :development)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
revelry_core-0.1.4 lib/revelry_core/engine.rb
revelry_core-0.1.3 lib/revelry_core/engine.rb
revelry_core-0.1.2 lib/revelry_core/engine.rb
revelry_core-0.1.1 lib/revelry_core/engine.rb
revelry_core-0.1.0 lib/revelry_core/engine.rb
revelry_core-0.0.1 lib/revelry_core/engine.rb
revelry_core-0.0.0 lib/revelry_core/engine.rb