Module: Depo::ViewHelpers

Defined in:
lib/depo/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#add_ext(str, ext) ⇒ Object

check if ext presented and add if not



18
19
20
# File 'lib/depo/view_helpers.rb', line 18

def add_ext(str,ext)
  ( str.strip=~/\.#{ext}$/ ) ? str.strip : "#{str.strip}.#{ext}"
end

#app_jsObject



39
40
41
# File 'lib/depo/view_helpers.rb', line 39

def app_js
  %Q[#{webroot}/#{app_package}/pages/#{@opts[:app]}.js]
end

#app_packageObject



13
14
15
# File 'lib/depo/view_helpers.rb', line 13

def app_package
  @app_package||=Depo.config.app_package
end

#cssObject



22
23
24
# File 'lib/depo/view_helpers.rb', line 22

def css
  %Q[#{webroot}/#{app_package}/themes/#{theme}/#{add_ext(@opts[:app],'css')}]
end

#djConfigObject



9
10
11
# File 'lib/depo/view_helpers.rb', line 9

def djConfig
  Depo.config.env_dj_config(@opts[:env])
end

#dojo(opts) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/depo/view_helpers.rb', line 26

def dojo(opts)
  return @dojo_tpl if @dojo_tpl
  raise "You must provide :app name in opts" unless opts[:app] 
  @opts = opts
  @opts[:env] = (defined? RAILS_ENV && !opts[:env])? RAILS_ENV : opts[:env]
  tpl_string = File.read("#{File.dirname(__FILE__)}/templates/dojo_src.tpl")
  @dojo_tpl = ERB.new(tpl_string).result(binding)
end

#themeObject



35
36
37
# File 'lib/depo/view_helpers.rb', line 35

def theme
  Depo.config.default_theme
end

#webrootObject



5
6
7
# File 'lib/depo/view_helpers.rb', line 5

def webroot
  Depo.config.env_root_webpath(@opts[:env])
end