Module: Pakunok::Helpers::AssetsHelper

Defined in:
lib/pakunok/helpers/assets_helper.rb

Instance Method Summary collapse

Instance Method Details

#include_javascripts(path = nil) ⇒ Object



9
10
11
# File 'lib/pakunok/helpers/assets_helper.rb', line 9

def include_javascripts(path=nil)
  include_pakunok_assets :javascript, path
end

#include_pakunok_assets(asset_type, path = nil) ⇒ Object



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

def include_pakunok_assets(asset_type, path=nil)
  p = pakunok_assets
  path = path || (
    request.params[:controller] + {:javascript => '.js', :stylesheet => '.css'}[asset_type]
  ).to_s

  @pakunok_context ||= ::Pakunok::HttpContext.new(request)
  renderer = p.renderer_for(p.render_types.fetch asset_type)
  renderer.render(@pakunok_context, path).html_safe
end

#include_stylesheets(path = nil) ⇒ Object



13
14
15
# File 'lib/pakunok/helpers/assets_helper.rb', line 13

def include_stylesheets(path=nil)
  include_pakunok_assets :stylesheet, path
end

#pakunok_assetsObject



5
6
7
# File 'lib/pakunok/helpers/assets_helper.rb', line 5

def pakunok_assets
  ::Pakunok::Pakunok.current
end