Sha256: a5ba15e44c4d200be01cb01a4cc75189dcfb1673a2ab36987dbee4d2d99d159e

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 Bytes

Contents

module InterfaceBuilder
  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? "#{InterfaceBuilder.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 ||= InterfaceBuilder::Theme.new
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-ext-0.3.27 lib/interface_builder/controller_helper.rb