Sha256: 8266d34360d4c669443c710414ccc5e146d941470d2875def0bab9b7bc03cbfc
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
# Extend the Base ActionController to support themes # ActionController::Base.class_eval do attr_accessor :current_theme attr_accessor :force_liquid_template def self.theme(theme_name, conditions = {}) # TODO: Allow conditions... (?) write_inheritable_attribute "theme", theme_name end def self.force_liquid(force_liquid_value, conditions = {}) # TODO: Allow conditions... (?) write_inheritable_attribute "force_liquid", force_liquid_value end # You need to override this in your +ApplicationController+ # This should return the current theme name 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 def force_liquid_template(passed_value=nil) force_liquid = passed_value || self.class.read_inheritable_attribute("force_liquid") force_liquid_template = case force_liquid when Symbol then send(force_liquid) when Proc then force_liquid.call(self) when String then force_liquid == 'true' when TrueClass then force_liquid when FalseClass then force_liquid when Fixnum then force_liquid == 1 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
theme_generator-1.2.0 | templates/actioncontroller_ex.rb |