-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fallbacks to base theme and inheritance #40
Comments
As given in the README, you could either define method or Proc for this in the controller. theme :default_theme
private
def default_theme
theme || parent_theme || "layout_name"
end |
@yogeshjain999 So you pass the default layout as the fallback theme? |
Correct @iamdriz. It is because search locations includes |
@yogeshjain999 That being said though.... If I have:
I'm finding that instead of it falling back to the |
That being said, easiest way I can see is doing it like, def theme_resolver
theme_present?('a_theme_that_doesnt_exist') || 'application'
end
def theme_present?(name)
return name if Rails.application.paths["app/themes/#{name}"].present?
end |
@yogeshjain999 The theme may exist but the view for that particular request may not. |
In order to get the fallback theme to work I had to do:
|
It also turns out that it doesn't actually use the fallback string:
So it would be good to pass back a nil if no theme is specified. Rather than a string that is basically ignored as the default paths are already in the |
After playing around with this I've come to find that building a Rails Engine is probably a better way forward as then it means you can have everything a Rails app would have on a theme basis. |
How can we have it so that if no theme is found it falls back to the default
app/views
?And using this same mechanism would it be possible to get it to first look in the theme folder, then have a parent theme to fallback to and then finally the default Rails folder if it can't be found.
The text was updated successfully, but these errors were encountered: