-
Notifications
You must be signed in to change notification settings - Fork 442
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
Deprecate Base#with_variant #1041
Conversation
We are using variants, right now, to define two different templates for the same component. Reading the suggestions above:
How can we still render a specific variant explicitly? This does not seem possible otherwise.
Passing each time the template name, to the component will for sure work, so, the idea would be that I pass a
This is not an option for us since we have about 10 components all inheriting from the same parent. |
@coorasse I'm not sure how complicated your templates are, but perhaps you could combine them together into a single template for the component and use conditional logic to switch between each mode, say with a |
Thanks for the input. |
Summary
Deprecates
Base#with_variant
. Variants are an often misunderstood feature that use the Action Pack variant information present in the request (i.e. phone, tablet, etc) to render a component differently depending on the requesting device. Normally one passes in a list of acceptable variants in an Action View template, eg:The variant can be overridden by calling
#with_variant
on the component, eg:It's important to note that these are two distinct
render
functions (the second does not accept a:variants
option). Since components don't have access to the request object, it doesn't really make sense for them to decide which variant to render (that's probably why:variants
isn't available in the first place). The consensus on the team was that overriding the variant is something that should really only be done in a test environment and not supported otherwise.