Sha256: 9597dac4e58f4236e0a71eef12e9d8aa7324ef90da9e9234f15d4a0607a9f832

Contents?: true

Size: 831 Bytes

Versions: 5

Compression:

Stored size: 831 Bytes

Contents

module AbstractInterface
  module ControllerHelper
    TEMPLATE_EXTENSIONS = ['html.haml', 'html.erb']

    def themed_partial_exist? partial
      partial = partial + "_t"
      
      partial_fname = if pos = partial.index('/')
        partial.clone.insert(pos + 1, '_')
      else
        "_#{partial}"
      end
      
      TEMPLATE_EXTENSIONS.any?{|ext| File.exist? "#{AbstractInterface.themes_dir}/#{current_theme.name}/#{partial_fname}.#{ext}"}
    end    
    cache_with_params! :themed_partial_exist? unless Rails.development?
    
    def themed_partial partial
      if themed_partial_exist? partial
        "/themes/#{current_theme.name}/#{partial}_t"
      else
        "/themes/default/#{partial}_t"
      end
    end
    
    def current_theme
      @current_theme ||= AbstractInterface::Theme.new
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
crystal-ext-0.0.3 lib/abstract_interface/old/controller_helper.rb
crystal-ext-0.0.2 lib/abstract_interface/old/controller_helper.rb
crystal-ext-0.0.1 lib/abstract_interface/controller_helper.rb
rails-ext-0.3.29 lib/abstract_interface/controller_helper.rb
rails-ext-0.3.28 lib/abstract_interface/controller_helper.rb