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} with A1, B2, and C3 respectively. 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] qux becomes qux.
  • 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

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