Sha256: c5843cf741ac8c12688bbdc6f4d9e966e324a71175c07456cdebd3cb507ee2b9

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

# 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
module LayoutHelper
  def title(page_title, show_title = true)
    content_for(:title) { h(page_title.to_s) }
    @show_title = show_title
  end

  def show_title
    @show_title
  end

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

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

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

  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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flexi_generators-0.3.4 lib/generators/flexi/layout/templates/layout_helper.rb
flexi_generators-0.3.3 lib/generators/flexi/layout/templates/layout_helper.rb
flexi_generators-0.3.2 lib/generators/flexi/layout/templates/layout_helper.rb
flexi_generators-0.3.1 lib/generators/flexi/layout/templates/layout_helper.rb