Module: LayoutHelper

Defined in:
lib/generators/flexi/layout/templates/layout_helper.rb

Overview

These helper methods can be called in your template to set variables to be used in the layout This module should be included in all views globally, to do so you may need to add this line to your ApplicationController

helper :layout

Instance Method Summary collapse

Instance Method Details

#analytics(site_id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/generators/flexi/layout/templates/layout_helper.rb', line 27

def analytics(site_id)
  html = <<-ANALYTICS
  <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', '#{site_id}']);
    _gaq.push(['_trackPageview']);
    (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
  </script>
  ANALYTICS

  html.html_safe if Rails.env.production?
end

#app_nameObject



44
45
46
# File 'lib/generators/flexi/layout/templates/layout_helper.rb', line 44

def app_name
  Rails.application.class.to_s.split("::").first
end

#javascript(*args) ⇒ Object



19
20
21
# File 'lib/generators/flexi/layout/templates/layout_helper.rb', line 19

def javascript(*args)
  content_for(:javascript) { javascript_include_tag(*args) }
end


23
24
25
# File 'lib/generators/flexi/layout/templates/layout_helper.rb', line 23

def menu(name, path)
  (:li, link_to(name, path), :class => "#{'active' if request.path.gsub(/(.[^\/]+|\/)/).first == path}")
end

#show_titleObject



11
12
13
# File 'lib/generators/flexi/layout/templates/layout_helper.rb', line 11

def show_title
  @show_title
end

#stylesheet(*args) ⇒ Object



15
16
17
# File 'lib/generators/flexi/layout/templates/layout_helper.rb', line 15

def stylesheet(*args)
  content_for(:stylesheet) { stylesheet_link_tag(*args) }
end

#title(page_title, show_title = true) ⇒ Object



6
7
8
9
# File 'lib/generators/flexi/layout/templates/layout_helper.rb', line 6

def title(page_title, show_title = true)
  content_for(:title) { h(page_title.to_s) }
  @show_title = show_title
end