Replace a word in a custom block or paragraph with a token related to a content type field value I have a content type with a mix of paragraphs and custom blocks.
Most custom blocks (content) are the same on all pages except for one word that needs to be replaced by an other one.
I would like to replace that word with an other one related to a field on the content type page.
I thought it could be done with Token Filter (https://www.drupal.org/project/token_filter) but that is not an option.
EDIT 2: explain with example
I have a content type 'CMS page'. It has a field 'field_brand_name'. This field is used to replace a string in paragraphs or custom blocks that exists on the content type page.
If I create a page for Magento and a page for Drupal and a page for WordPress. The only that needs to be replaced is the brand name in the text (Magento, Drupal or WordPress) on all custom blocks or paragraphs that I have used on that specific CMS page ... That could be resolved by a Token if there was a context for it, but there is no ... so the token is not replaced. Is that clear enough?
First create your own module.
In mymodule_tokens.module insert below:
&lt;?php

use Drupal\Core\Render\BubbleableMetadata;

/**
 * Implements hook_token_info().
 */

function mymodule_tokens_token_info(): array
{
    $type = array(
        'name' =&gt; t('My Module Tokens'),
        'description' =&gt; t('Custom tokens to solve use-case problems for the website.'),
    );
    $node['brand'] = array(
        'name' =&gt; t(&quot;Brand name from node&quot;),
        'description' =&gt; t(&quot;Brand name to replace in text, custom blocks, paragraphs, ...&quot;),
    );
    return array(
        'types' =&gt; array(
            'mymodule_tokens' =&gt; $type,
        ),
        'tokens' =&gt; array(
            'mymodule_tokens' =&gt; $node,
        ),
    );
}

/**
 * Implements hook_tokens().
 */

function mymodule_tokens_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata): array
{
    $replacements = [];

    if ($type == 'mymodule_tokens') {
        foreach ($tokens as $name =&gt; $original) {
            switch ($name) {
                case 'brand':
                    $node = \Drupal::routeMatch()-&gt;getParameter('node');
                    if ($node instanceof \Drupal\node\NodeInterface) {
                        if ($node-&gt;hasField('field_brand') &amp;&amp; !$node-&gt;get('field_brand')-&gt;isEmpty()) {
                            $brand_name = $node-&gt;field_brand-&gt;value;
                            $replacements[$original] = $brand_name;
                        } else {
                            $replacements[$original] = null;
                        }
                    }
                    break;
                default:
                    break;
            }
        }
    }

    return $replacements;
}