I used Node title field block that from Layout builder, but this module not have support the field block, so I did some work on it.
I add a function preprocess hook for field--node--title twig.Get twig data before render it,get content and use decodeToMarkup function to decode html tag.

/**
 * Implements hook_preprocess_HOOK
 */
function html_title_preprocess_field__node__title(&$vars) {
  if ($vars && !empty($vars['field_name']) && $vars['field_name'] == 'title' && $vars['entity_type'] == 'node') {
    if (is_array($vars['items']) && !empty($vars['items'])) {
      foreach($vars['items'] as $key => $value) {
        $item_text = $vars['items'][$key]['content']['#context']['value'];
        $vars['items'][$key]['content']['#context']['value'] = \Drupal::service('html_title.filter')->decodeToMarkup($item_text);
      }
    }
  }
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zhaoyao@ciandt.com created an issue. See original summary.

zhaoyao@ciandt.com’s picture

Added a hook for _preprocess_field__node__title in this module to handle node title before twig render

himanshu_sindhwani’s picture

Status: Active » Needs review
JeroenT’s picture

Status: Needs review » Needs work

The last submitted patch, 4: 3157350-4-test-only.patch, failed testing. View results

  • JeroenT committed 5db8933 on 8.x-1.x
    Issue #3157350 by JeroenT, zhaoyao@ciandt.com: Support node title about...
  • JeroenT committed a4b0641 on 8.x-1.x authored by zhaoyao@ciandt.com
    Issue #3157350 by JeroenT, zhaoyao@ciandt.com: Support node title about...
JeroenT’s picture

Status: Needs work » Fixed

Committed and pushed to 8.x-1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.