Sha256: 2214014a6434e114d2becb8e9a7a23c83f811aa947dfede2cac0c4f522cb15ce
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
module ThemesForRails module CommonMethods def view_path_for(theme) File.join(theme_path_for(theme), "views") end def theme_name @cached_theme_name ||= begin case @theme_name when Symbol then self.respond_to?(@theme_name) ? self.send(@theme_name) : @theme_name.to_s when String then @theme_name else nil end end end def theme_name=(name) @theme_name = name end def set_theme(name) self.theme_name = name if valid_theme? add_theme_view_path end end public def valid_theme? !self.theme_name.nil? end # will add the view path for the current theme def add_theme_view_path add_theme_view_path_for(self.theme_name) end # will add the view path for a given theme name def add_theme_view_path_for(name) self.view_paths << ActionView::FileSystemResolver.new(view_path_for(name)) end def public_theme_path theme_path("/") end def theme_path(base = ::Rails.root) theme_path_for(theme_name, base) end def theme_path_for(name, base = ::Rails.root) File.join(base, "themes", name) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
themes_for_rails-0.2.2 | lib/themes_for_rails/common_methods.rb |
themes_for_rails-0.2.1 | lib/themes_for_rails/common_methods.rb |