Sha256: 05e913b326274be890cdbe43d0ebf5dd9d193354769e21c1d545cf7bfdb39744

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module Ecm::CmsCoreHelper
  def cms_body_classes
    url_for().gsub("/", " ").strip!
  end
  
  def cms_page_stylesheets(namespace = nil)
    output = ""
    if namespace
      namespace_string = "#{namespace}/"
    else
      namespace_string = ""
    end
    url_for().split("/").each do |path_part|
      output << stylesheet_link_tag("#{namespace_string}#{path_part}.css", :media => 'screen') unless path_part.blank? || path_part.length == 1
    end
    output.html_safe
  end      
  
  def cms_title(site_title = "Change me")
    return "#{site_title} - #{@title}" if @title
    site_title
  end
  
  def cms_meta_description
    @meta_description
  end  
  
  def render_fragment(name)
    if controller_name == 'page'
      page = (params[:page].nil?) ? "home" : params[:page]
    else
      page = request.fullpath.gsub(/\/#{I18n.locale}\//, '')
    end  
    
    path = "#{name.to_s}/#{page}"
    full_path = "#{I18n.locale}/#{path}"

    begin 
      render path
    rescue ActionView::MissingTemplate => e
      if Rails.env.production?
        return nil
      else 
        return I18n.t("ecm.cms_core.warnings.missing_fragment", :name => full_path)
      end        
    end  
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ecm_cms_core-0.0.3 app/helpers/ecm/cms_core_helper.rb
ecm_cms_core-0.0.2 app/helpers/ecm/cms_core_helper.rb