You are here

public function NodeHtmlTitle::renderText in HTML Title 8

Performs an advanced text render for the item.

This is separated out as some fields may render lists, and this allows each item to be handled individually.

Parameters

array $alter: The alter array of options to use.

  • max_length: Maximum length of the string, the rest gets truncated.
  • word_boundary: Trim only on a word boundary.
  • ellipsis: Show an ellipsis (…) at the end of the trimmed string.
  • html: Make sure that the html is correct.

Return value

string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

Overrides FieldPluginBase::renderText

File

src/Plugin/views/field/NodeHtmlTitle.php, line 48

Class

NodeHtmlTitle
A field that displays node html title.

Namespace

Drupal\html_title\Plugin\views\field

Code

public function renderText($alter) {
  if ($this->options['settings']['link_to_entity'] === TRUE) {
    $alter['rendered']['#title']['#context']['value'] = $this->htmlTitleFilter
      ->decodeToMarkup($alter['rendered']['#title']['#context']['value']);
    $this->last_render = $this->renderer
      ->render($alter['rendered']);
  }
  else {
    $rendered = $this->renderer
      ->render($alter['rendered']);
    $this->last_render = $this->htmlTitleFilter
      ->decodeToMarkup($rendered);
  }
  return parent::renderText($alter);
}