Sha256: 153afd833ed579c6a3b56779a828a7951ff6200ff8cd80d6dc985b2f01d4eec0
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
# Extend the Base ActionView to support rendering themes # module ActionView class ThemeError < StandardError end class Base alias_method :__render_file, :render_file def render_file(template_path, use_full_path = true, local_assigns = {}) search_path = [ "../themes/#{controller.current_theme}/views", # for components "../../themes/#{controller.current_theme}/views", # for normal views "../../themes/#{controller.current_theme}", # for layouts "." # fallback ] if use_full_path search_path.each do |prefix| theme_path = prefix +'/'+ template_path begin template_extension = pick_template_extension(theme_path) # Prevent .rhtml (or any other template type) if force_liquid == true if controller.force_liquid_template and template_extension.to_s != 'liquid' and prefix != '.' raise ThemeError.new("Template '#{template_path}' must be a liquid document") end local_assigns['active_theme'] = controller.current_theme unless controller.current_theme.nil? rescue ActionView::ActionViewError => err next rescue ThemeError => err # Should it raise an exception, or just call 'next' and revert to # the default template? raise err end return __render_file(theme_path, use_full_path, local_assigns) end else __render_file(template_path, use_full_path, local_assigns) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
theme_generator-1.2.0 | templates/actionview_ex.rb |
theme_generator-1.2.2 | templates/actionview_ex.rb |
theme_generator-1.2.1 | templates/actionview_ex.rb |