Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Rules 8.x decided to use Twig-style token replacements to provide more flexibility by using filters.
Example tokens will look like the following:
{{ node.field_integer.2.value | default('0') }}
{{ node.title.value | default('tEsT') | lower }}
For now, look at the PlaceholderResolver class to see how it has been implemented and the following issues: #2650440: Add data filter plugins, #2648918: Add new token replacement API (service), #2650426: Document twig syntax for placeholder replacements.
Further tasks are available as sub-issues.
This is an alternative approach to the token module, see their related issue: #2430827: [meta] Improve field support and add test coverage
Comments
Comment #2
fagoSome related spin-offs:
#2650424: Implement translation / langcode for data fetcher and placeholder replacements
#2650426: Document twig syntax for placeholder replacements
#2650436: Check (field) access when fetching data and replacing placeholders
#2655020: Auto-convert filter input to string if necessary
#2655024: Improve default value filter to work on non-existing list items
#2655026: Datafilter: Add format_date filter and add bubbleablemetadata test-coverage
#2655028: Improve default value filter to support more data types
Comment #3
fagoConverted Rules token processor to use the new system, so let's call this fixed.
Comment #5
klausiLeft a comment in https://github.com/fago/rules/pull/358
Shouldn't this convert stuff to use "." instead of ":" separators?
Comment #6
fago>Shouldn't this convert stuff to use "." instead of ":" separators?
Yep, I fixed that already in a follow-up. Check 8.x-3.x.
Comment #8
dasjorenaming this to cover all token-related efforts (entity, typed data, twig-style replacements, ...)
Comment #9
dasjoReopening to summarize what we have done related to tokens so far and to keep track of further issues via sub-tasks.
Comment #10
dasjoComment #11
fagoI don't think keeping this open gives the right picture: it looks like it is not implemented, but it is. Maybe we can do a new meta for token system improvements?
-> Setting this to fixed to avoid further confusion.