Module: Initjs::Helper

Defined in:
lib/initjs/helper.rb

Instance Method Summary collapse

Instance Method Details

#initjs_tag(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/initjs/helper.rb', line 3

def initjs_tag options = {}
  options = { app_name: options } unless options.is_a?(Hash)
  if options[:partial] && options[:partial] == true
    id = 'init-partial-js'
  else
    id = 'init-js'
  end

   'div', '', { id: id,
                           :"data-resource" => controller.controller_path.split('/').map(&:camelize).join('/'),
                           :"data-action" => controller.action_name.camelize,
                           :"data-app-name" => options[:app_name] || "App"}
end