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

  1. Create a pattern with variants
  2. Implement a variant template (ie. @pattern-ID--variant-VID.html.twig@)
  3. 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.

CommentFileSizeAuthor
#3 3525646-3.patch4.16 KBduaelfr
Command icon 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

duaelfr created an issue. See original summary.

duaelfr’s picture

Assigned: duaelfr » Unassigned
Status: Active » Needs review
StatusFileSize
new4.16 KB

Done
Patch attached for composer

pdureau’s picture

duaelfr’s picture

@pdureau I rebased the MR on the latest commit.

pdureau’s picture

Assigned: pdureau » grimreaper
Status: Needs review » Reviewed & tested by the community

Looks OK to me but there is a little voice tell me to be cautious.

@grimreaper: Do you want to have also a look?

grimreaper’s picture

Assigned: grimreaper » duaelfr
Status: Reviewed & tested by the community » Needs work

One review comment.

duaelfr’s picture

Status: Needs work » Needs review
grimreaper’s picture

Status: Needs review » Reviewed & tested by the community

I have not executed the code, but good for me now!

Thanks :)

pdureau’s picture

Status: Reviewed & tested by the community » Needs work

Edouard, you can merge but there is a phpstan error to fix first.

duaelfr’s picture

Assigned: duaelfr » Unassigned
Status: Needs work » Needs review

phpstan should be fixed now but I'm not sure it's the best way...
May I have an ultimate review on this?

grimreaper’s picture

Status: Needs review » Reviewed & tested by the community

Ok for me.

  • pdureau committed 597df7ef on 2.0.x authored by duaelfr
    Issue #3525646 by duaelfr, grimreaper: [2.1.0] Copy variant templates...
pdureau’s picture

Title: [2.1.0] Copy variant templates when converting patterns to components » [2.0.5] Copy variant templates when converting patterns to components
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.