Module: LjaxRails::LjaxRenderer

Defined in:
lib/ljax_rails/action_view_monkey.rb

Instance Method Summary collapse

Instance Method Details

#render_partial(context, options, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ljax_rails/action_view_monkey.rb', line 5

def render_partial(context, options, &block)
  if options[:locals] && options[:locals].delete(:remote)
    partial = options.delete :partial
    encrypted_partial = LjaxRails.encryptor.encrypt_and_sign partial

    url = options[:locals].delete :remote_url
    id = "ljax-#{SecureRandom.uuid}"
    loading = block.call if block

    %Q!<div id="#{id}" class="ljax-container" data-ljax-partial="#{encrypted_partial}"#{%Q( data-remote-url="#{url}") if url}>#{loading}</div>!.html_safe
  else
    super
  end
end