Class: Archangel::Theme::ThemableController
- Inherits:
-
Object
- Object
- Archangel::Theme::ThemableController
- Defined in:
- lib/archangel/theme/themable_controller.rb
Overview
Apply Archangel theme to page
Instance Attribute Summary collapse
-
#theme_name ⇒ Object
readonly
Theme name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(controller, theme) ⇒ ThemableController
constructor
Theme initializer.
-
#theme_view_path ⇒ String
Archangel theme path.
Constructor Details
#initialize(controller, theme) ⇒ ThemableController
Theme initializer
66 67 68 69 |
# File 'lib/archangel/theme/themable_controller.rb', line 66 def initialize(controller, theme) @controller = controller @theme_name = theme_name_identifier(theme) end |
Instance Attribute Details
#theme_name ⇒ Object (readonly)
Theme name
15 16 17 |
# File 'lib/archangel/theme/themable_controller.rb', line 15 def theme_name @theme_name end |
Class Method Details
.apply_theme(controller_class, theme, options = {}) ⇒ Object
Apply theme
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/archangel/theme/themable_controller.rb', line 25 def apply_theme(controller_class, theme, = {}) filter_method = before_filter_method() = .slice(:only, :except) controller_class.class_eval do define_method :layout_from_theme do theme_instance.theme_name end alias_method :current_theme, :layout_from_theme define_method :theme_instance do @theme_instance ||= Archangel::Theme::ThemableController.new(self, theme) end private :layout_from_theme, :theme_instance layout :layout_from_theme, helper_method :current_theme end controller_class.send(filter_method, ) do |controller| controller.prepend_view_path theme_instance.theme_view_path end end |
Instance Method Details
#theme_view_path ⇒ String
Archangel theme path
76 77 78 79 80 81 |
# File 'lib/archangel/theme/themable_controller.rb', line 76 def theme_view_path path = Rails.root path = Archangel::Engine.root if @theme_name == Archangel::THEME_DEFAULT "#{path}/app/themes/#{@theme_name}/views" end |