Top Level Namespace

Defined Under Namespace

Modules: Kckstrt

Instance Method Summary collapse

Instance Method Details

#asset_hostObject



35
36
37
# File 'lib/kckstrt/templates/app/helpers/helpers.rb', line 35

def asset_host
  ENV['ASSET_HOST'] || ''
end

#asset_path(file_name) ⇒ Object

Assets helpers



2
3
4
5
6
7
8
9
10
# File 'lib/kckstrt/templates/app/helpers/helpers.rb', line 2

def asset_path(file_name)
  if ENV['RACK_ENV'] == 'development'
    file_name = Assets[file_name].logical_path + '?body=1'
  else
    file_name = Assets[file_name].digest_path
  end

  "#{asset_host}/assets/#{file_name}"
end

#dependencies_paths(file_name) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/kckstrt/templates/app/helpers/helpers.rb', line 12

def dependencies_paths(file_name)
  if ENV['RACK_ENV'] == 'development'
    Assets[file_name].to_a.map { |dep| dep.logical_path + '?body=1' }
  else
    [Assets[file_name].digest_path]
  end
end

#home_pathObject

URL helpers



46
47
48
# File 'lib/kckstrt/templates/app/helpers/helpers.rb', line 46

def home_path
  '/'
end

#inline_script_tag(file_name) ⇒ Object



30
31
32
33
# File 'lib/kckstrt/templates/app/helpers/helpers.rb', line 30

def inline_script_tag(file_name)
  file_name = "#{file_name}.js"
  '<script>' + Assets[file_name].source + '</script>'
end

#javascript_include_tag(file_name) ⇒ Object



20
21
22
23
# File 'lib/kckstrt/templates/app/helpers/helpers.rb', line 20

def javascript_include_tag(file_name)
  file_name = "#{file_name}.js"
  dependencies_paths(file_name).map { |path| %(<script src="#{asset_host}/assets/#{path}"></script>) }.join
end

#partial(partial, locals = {}) ⇒ Object

View helpers



40
41
42
43
# File 'lib/kckstrt/templates/app/helpers/helpers.rb', line 40

def partial(partial, locals={})
  partial_view = "partials/_#{partial}".to_sym
  erb partial_view, :layout => false, locals: locals
end


25
26
27
28
# File 'lib/kckstrt/templates/app/helpers/helpers.rb', line 25

def stylesheet_link_tag(file_name)
  file_name = "#{file_name}.css"
  dependencies_paths(file_name).map { |path| %(<link rel="stylesheet" href="#{asset_host}/assets/#{path}">) }.join
end