pattern-lab / patternlab-node

The Node version of Pattern Lab
http://patternlab.io
MIT License
2.05k stars 405 forks source link

Add core support for Data Transform Plugin requirements #1020

Open aleksip opened 5 years ago

aleksip commented 5 years ago

Background

Data Transform Plugin is a popular (over 470 000 installs according to Packagist) plugin for Pattern Lab PHP. It is especially useful in Drupal front end development. It is possible that some users don't even realize that the features provided by Data Transform Plugin are not part of Pattern Lab PHP core.

A Node version of Data Transform Plugin would make migration from Pattern Lab PHP to Pattern Lab Node easier for many people.

Based on my limited knowledge of JavaScript and the Pattern Lab Node codebase, it seems to me that it is not currently possible to create a Node version, due to missing core support for some requirements. If it turns out that core does support all requirements, it would still be good to know the 'right' way to do these things!

Technical description and requirements

Data Transform Plugin processes data in pattern data files and makes the processed data available to patterns. Other patterns can be included in data files and pattern specific data is also made available to patterns included in the templates themselves.

stale[bot] commented 5 years ago

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

sghoweri commented 5 years ago

+1

christianwiedemann commented 5 years ago

+1

stale[bot] commented 4 years ago

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

stale[bot] commented 4 years ago

Issue closed after going stale. It can be re-opened if still relevant.

juranosaurustechs commented 4 years ago

Still interested in seeing this happen...

RainbowArray commented 4 years ago

Aleksi mentioned this issue's existence to me, and I wanted to comment on it to make clear its importance.

The Data Transform Plugin has been absolutely critical in the work I've done integrating Drupal sites with Pattern Lab. By allowing patterns to be included through yml files, including the ability to override variables while doing so, this actually helps to replicate a similar data model to how variables work in the Drupal render system. In Drupal, higher-level templates like a page or a node pull in lower-level templates like a field through a variable that has already been rendered into a string. And essentially the Data Transform Plugin makes it simple to replicate that within the variable system in Pattern Lab, which makes it much simpler to use the same set of templates in Pattern Lab and in Drupal for front-end components.

This has become particularly important because Drupal 9 now uses Twig 2. And the original composer-based PHP version of Pattern Lab isn't really being supported anymore, so it's hard to see how that version will be upgraded to use Twig 2.

The node-based version of Pattern Lab with the PHP engine for Twig does seem much more actively maintained. However, the lack of support for plugins, particularly the Data Transform Plugin, has for me been the primary barrier for adoption. There are a lot of front-end developers in the Drupal community who make use of Pattern Lab, and the Data Transform Plugin has been a really useful tool in that process. It will be much, much easier for those developers to migrate to the node-based version of Pattern Lab if the Data Transform Plugin is available.

If that plugin is not available, frankly, I think it will be a blocker for upgrading to Drupal 9 altogether, because the barriers to dealing with that big of a change to the data model for Pattern Lab templates may be too large.

So support for this would be a huge help in adopting the node version of Pattern Lab for a lot of people in the Drupal community.

markconroy commented 4 years ago

I'm in pretty much the same boat as @mdrummond

If there's anything I can do to help this issue along, I'd be happy to try take a look and/or test things.

mariohernandez commented 3 years ago

Throwing in my hat in here as well. The Data Transform Plugin would be a great addition to node-based Pattern Lab.

aleksip commented 3 years ago

Adding the required support for plugins could prove to be a lot of work. Full PHP support would probably also require changes to both engine-twig-php and the "third-party" basalt/twig-renderer.

An alternative that has come to mind is to add (most of) Data Transform Plugin's features directly into core!

Of all DTP's features

only the last two require Twig or PHP. All other features could actually be quite useful for other (template) languages too. (Although not extensively tested, all DTP's non-Twig features should work with PL PHP's Mustache PatternEngine as well.)

PHP support would also be needed for pattern-specific data support for patterns included from Twig. But I am not sure if this is a very common use case, since usually the required variables are also passed with the Twig include.

The number one feature quite certainly is the ability to include patterns from data files. So maybe we could start with that?