Sha256: d463c97f35df9c55af8c8c2543a0bae54ae602275396edc970ddef836cf45372

Contents?: true

Size: 779 Bytes

Versions: 3

Compression:

Stored size: 779 Bytes

Contents

require_dependency 'lazy_render/application_controller'

module LazyRender
  class LazyloadController < ApplicationController
    protect_from_forgery with: :null_session

    def load
      return unless params['lazy_renders']
      result = []
      @data  = {}
      params['lazy_renders'].values.select { |v| v['name'] && respond_to?(v['name']) }.each do |v|
        data = {
            name:   v['name'],
            locals: v['locals'] || {}
        }
        data[:locals].empty? ? send(data[:name]) : send(data[:name], data[:locals])
        # TODO: Add Benchmark time
        html = render_to_string 'lazy_render/' + data[:name].gsub('__', '/'), layout: false, locals: { data: @data || {} }
        result << html
      end

      render json: result
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lazy_render-0.2.1 app/controllers/lazy_render/lazyload_controller.rb
lazy_render-0.2.0 app/controllers/lazy_render/lazyload_controller.rb
lazy_render-0.1.3 app/controllers/lazy_render/lazyload_controller.rb