Module: AssetLibrary::Helpers

Defined in:
lib/asset_library/helpers.rb

Defined Under Namespace

Classes: Priv

Instance Method Summary collapse

Instance Method Details

#asset_library_javascript_tags(module_key, format = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/asset_library/helpers.rb', line 5

def asset_library_javascript_tags(module_key, format = nil)
  
  m = AssetLibrary.asset_module(module_key)
  if AssetLibrary.cache
    AssetLibrary.cache_vars[:javascript_tags] ||= {}
    AssetLibrary.cache_vars[:javascript_tags][module_key] ||= asset_library_priv.script_tag(m.cache_asset)
  else
    m.assets(format).collect{|a| asset_library_priv.script_tag(a)}.join("\n")
  end
end

#asset_library_stylesheet_tags(module_key, *args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/asset_library/helpers.rb', line 16

def asset_library_stylesheet_tags(module_key, *args)
  html_options = args.last.is_a?(Hash) ? args.pop : {}
  format = args[0]
  
  m = AssetLibrary.asset_module(module_key)
  if AssetLibrary.cache
    AssetLibrary.cache_vars[:stylesheet_tags] ||= {}
    AssetLibrary.cache_vars[:stylesheet_tags][[module_key, format, request.protocol, request.host_with_port]] ||= asset_library_priv.style_tag(m.cache_asset(format), html_options)
  else
    asset_library_priv.import_styles_tag(m.assets(format), html_options)
  end
end