Major improvements for the Rewrite plugin; new Twig plugin; translatable categories; attribute support
Highlights in this release:
- The Rewrite plugin got a major update (no BC breaks).
- New plugin: Twig, written by codebymikey.
- The category of a Tamper plugin is now translatable. Modules providing Tamper plugins should define these translatable as well. See the change record.
- Attribute support is added. The Tamper plugins itself are not converted to attributes yet, that is planned for the next release.
- This is the last release to support Drupal 8 and 9. In order to prepare already a bit for Drupal 12 support, the next release will require at least Drupal 10.3.
Improved Rewrite plugin features:
- Array handling: When using two array sources in a replacement pattern, the plugin now iterates over the first array and matches values from the second array by key. Example:
[foo, bar](source 1) +[.jpg, .png](source 2) becomes[foo.jpg, bar.png]. - Accessing child elements: You can now reference a child value from an array source, for example
[metadata.category]or[author.name]. - Key-based iteration (advanced): When working with arrays that share the same keys, you can now use the special placeholder
{key}in your replacement pattern. The plugin will automatically insert the current key when iterating.
For example, with[pricing.{key}.price]and the input array keyed by "A1", "B2", and "C3", the plugin will replace {key} withA1,B2, andC3respectively. So in essence, it looks for[pricing.A1.price],[pricing.B2.price], and[pricing.C3.price]respectively. - Cleanup of unused tokens: Unreplaced tokens are now removed automatically. For example, if the source does't have "foobar" defined,
[foobar] quxbecomesqux. - The Rewrite now also a method called
getUsedSourceProperties()that reports which fields/properties are used in the replacement pattern. This is useful for projects that use Tamper and want to lazy load data for certain properties. The latest release of Feeds Tamper uses this to lazy load data for[parent:*]sources.
Contributors (4)
megachriz, ptmkenny, codebymikey, baikho
Changelog
Issues: 13 issues resolved.
Changes since 8.x-1.0-beta1:
Bug
- #3497033 by megachriz: Fixed "Multiline Find/Replace" tamper plugin adds carriage return.
- #3280233 by megachriz: Fixed set value to TRUE if there is no match and the "If no match" setting is set to "True". Also added more test coverage.
- #3323381 by megachriz: Added test coverage for using the Rewrite plugin after the Find-replace plugin.
- #3517986 by baikho: Fixed Entity Finder Plugin should support configurable fields on content entities without bundles.
Feature
- #3419759 by megachriz: Hash plugin: added an option to create a hash of the current value (instead of the whole item).
- #3540763 by megachriz: Made "category" translatable in each Tamper plugin.
- #3224959 by megachriz, codebymikey: Rewrite plugin: iterate through values to rewrite and other improvements.
- #3530530 by codebymikey, megachriz: StrToTime: Allow using a custom date format.
- #3530101 by codebymikey: Added a twig rewrite plugin.
- #3541447 by megachriz: Make Tamper plugins tell which properties they use of a tamperable item.
Task
VCS Label
8.x-1.0-beta2
Core compatibility
Release type
Short description
Major improvements for the Rewrite plugin; new Twig plugin; translatable categories; attribute support
Packaged Git sha1
b8f373f9e83c0e689c22b80fd314cb622621c5c1
Release files