Sha256: e35e960ab617a163ece474062091aee1dcb4623d82249a9482e59b6e6b2664e1

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

module JellyHelper

  def application_jelly_files(jelly_files_path_from_javascripts = '', rails_root = RAILS_ROOT)
    Dir["#{rails_root}/public/javascripts/#{jelly_files_path_from_javascripts}/pages/**/*.js"].map do |path|
      path.gsub("#{rails_root}/public/javascripts/", "").gsub(/\.js$/, "")
    end
  end

  def spread_jelly
    javascript_tag <<-JS
      window._token = '#{form_authenticity_token}'
      Jelly.activatePage('#{controller.controller_path.camelcase}', '#{controller.action_name}');
      #{@content_for_javascript}
    JS
  end

  def clear_jelly_attached()
    @jelly_attached_components = []
  end

  def attach_javascript_component(component_name, *args)
    @jelly_attached_components ||= []    
    key = "page.attach(#{component_name}, #{args.to_json});"
    unless @jelly_attached_components.include? key
      @jelly_attached_components << key
      content_for(:javascript, key)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pivotal-jelly-0.3.5 lib/jelly/jelly_helper.rb