Sha256: e4b4f1cf6a1b82ac095f2de76d50bf0bd2e80437ec1052cafced8c7ab4120721

Contents?: true

Size: 666 Bytes

Versions: 10

Compression:

Stored size: 666 Bytes

Contents

module JellyController
  protected
  include Jelly::Common

  def jelly_callback(callback_base_name = @action_name, options = {}, &block)
    render :inline => jelly_callback_erb("on_#{callback_base_name}", options, block)
  end

  def jelly_callback_erb(callback_name, options, block)
    @callback_name = callback_name
    @options = options
    @block = block
    erb = <<-ERB
      <%= begin
        args = @block ? instance_eval(&@block) : []
        args = [args] unless args.is_a?(Array)
        jelly_callback_hash(@callback_name, *args).reverse_merge(@options).to_json
      end %>
    ERB
    request.xhr? ? erb : "<textarea>#{erb}</textarea>"
  end


end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
honkster-jelly-0.7.6 lib/jelly/jelly_controller.rb
honkster-jelly-0.7.5 lib/jelly/jelly_controller.rb
honkster-jelly-0.7.4 lib/jelly/jelly_controller.rb
honkster-jelly-0.7.3 lib/jelly/jelly_controller.rb
honkster-jelly-0.7.2 lib/jelly/jelly_controller.rb
honkster-jelly-0.7.1 lib/jelly/jelly_controller.rb
honkster-jelly-0.7.0 lib/jelly/jelly_controller.rb
honkster-jelly-0.6.7 lib/jelly/jelly_controller.rb
honkster-jelly-0.6.6 lib/jelly/jelly_controller.rb
jelly-0.6.5 lib/jelly/jelly_controller.rb