Problem/Motivation
When converting patterns to components using the @ui-patterns:migrate@ Drush command, we are notified of the existence of variant templates in our pattern with a message telling that variants doesn't exist in SDC so the template has not been migrated.
Steps to reproduce
- Create a pattern with variants
- Implement a variant template (ie. @pattern-ID--variant-VID.html.twig@)
- Run the migration command
Proposed resolution
Even if variant templates are not supported with SDC, that doesn't mean we cannot use variants to make variations on our markup. It's just a bit uglier because it relies on @if@ statements.
eg:
{% if variant == "my-variant" %}
markup here
{% elif variant == "my-other-variant" %}
other markup here
{% else %}
default markup here
{% endif %}We can tune the command to output that kind of file.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3525646-3.patch | 4.16 KB | duaelfr |
Issue fork ui_patterns-3525646
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
duaelfrDone
Patch attached for composer
Comment #4
pdureau commentedLet's merge #3525566: [2.0.5] Keep patterns directory structure when converting them to components first
Comment #5
duaelfr@pdureau I rebased the MR on the latest commit.
Comment #6
pdureau commentedLooks OK to me but there is a little voice tell me to be cautious.
@grimreaper: Do you want to have also a look?
Comment #7
grimreaperOne review comment.
Comment #8
duaelfrComment #9
grimreaperI have not executed the code, but good for me now!
Thanks :)
Comment #10
pdureau commentedEdouard, you can merge but there is a phpstan error to fix first.
Comment #11
duaelfrphpstan should be fixed now but I'm not sure it's the best way...
May I have an ultimate review on this?
Comment #12
grimreaperOk for me.
Comment #14
pdureau commented