Module: Suite::Helpers::JavascriptViewHelper

Included in:
ViewHelpers
Defined in:
lib/suite/helpers/javascript_view_helper.rb

Instance Method Summary collapse

Instance Method Details

#javascript_include_tag(path) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/suite/helpers/javascript_view_helper.rb', line 3

def javascript_include_tag path
  path = path + ".js" unless path =~ /\.js/
  if Suite.env.development?
    javascript_include_tags_for_asset(path)
  else
    javascript_script_tag "#{Suite.project.asset_path}/javascripts/#{Suite.project.asset_registry.add_asset :js, path}.js"
  end
end

#javascript_include_tags_for_asset(path) ⇒ Object



12
13
14
15
16
17
# File 'lib/suite/helpers/javascript_view_helper.rb', line 12

def javascript_include_tags_for_asset path
  assets = Suite.project.asset path
  assets.to_a.map do |asset|
    javascript_script_tag clean_asset_path asset.pathname.to_s
  end.join("\n")
end

#javascript_script_tag(path) ⇒ Object



19
20
21
# File 'lib/suite/helpers/javascript_view_helper.rb', line 19

def javascript_script_tag path
  "<script type=\"text/javascript\" src=\"#{path}\"></script>"
end