Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 297377

Add support for Twig into Token::replace

$
0
0

Suggestion: add support for Twig into token module so that we can print tokens based on conditions like:

{# Directly access field in node entity #}
{% if node.myfield|isEmpty is not false %}[node:myfield:value]{% endif %}

{# or loop through token based on the field value #}
{% for key in node.foo|keys %}
Item: [node:foo:{{ key }}]
{% endfor %}

{# or work with token value(two syntaxes) #}
{% if token('node:foo') is not empty and token('node', 'bar') %}
[node:foo] [node:bar]
{% endif %}

In order for this to be possible some token-specific filters/function would have to be added - specifically "token" function.

The Twig would run before token replacement but Twig would have access to token replacements right away.

With this in place we could have conditional e-mails, notifications, error messages, logs...


Viewing all articles
Browse latest Browse all 297377

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>