Sha256: 3c12c727d37e38dfeb4b0b813f06f913b01e70b2c177fd5f93118739cbe72815

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

class AbstractController::Base
  attr_accessor :current_theme
  attr_accessor :force_liquid_template

  # Use this in your controller just like the <tt>layout</tt> macro.
  # Example:
  #
  #  theme 'theme_name'
  #
  # -or-
  #
  #  theme :get_theme
  #
  #  def get_theme
  #    'theme_name'
  #  end

  def self.theme(theme_name, conditions = {})
    # TODO: Allow conditions... (?)
    write_inheritable_attribute "theme", theme_name
  end

  # Retrieves the current set theme
  def current_theme(passed_theme=nil)
    theme = passed_theme || self.class.read_inheritable_attribute("theme")

    @active_theme = case theme
      when Symbol then send(theme)
      when Proc   then theme.call(self)
      when String then theme
    end
  end
end

# Hack which uses layout theme but crashes if it doesn't exist !
# Now it loads the default layout
#AbstractController::Layouts.module_eval do
#  def _normalize_options(options)
#    super
#
#    if _include_layout?(options)
#      layout = options.key?(:layout) ? options.delete(:layout) : :default
#      value = _layout_for_option(layout)
#      options[:layout] = (value =~ /\blayouts/ ? value : "layouts/#{value}") if value
#    end
#
#    if current_theme
#      theme_path = File.join(Rails.root, "themes", current_theme, "views")
#      options[:layout] = File.join(theme_path, options[:layout])
#    end
#  end
#end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
theme_support-3.0.3 lib/theme_support/patches/abstractcontroller_ex.rb