Open aleksip opened 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!
+1
+1
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!
Issue closed after going stale. It can be re-opened if still relevant.
Still interested in seeing this happen...
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.
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.
Throwing in my hat in here as well. The Data Transform Plugin would be a great addition to node-based Pattern Lab.
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
Attribute
objectsUrl
objectsonly 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?
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.
Core should have a working plugin system (#1021).
Since an included pattern might not yet be rendered by core, the plugin needs to be able to render a pattern exactly as core would render it (#1022).
For performance reasons it would be ideal if the plugin had at least read access to all Pattern Lab data, so it can check if the included pattern is already rendered. Even better would be if the plugin had write access also, so that core does not have to render patterns already rendered by the plugin. (#1023)
To be able to add data for patterns included in Twig templates, the Twig engine needs similar access to all Pattern Lab data, also from PHP code (#1023).