public function HighlightShortcode::process in Shortcode 8
Same name and namespace in other branches
- 2.0.x shortcode_basic_tags/src/Plugin/Shortcode/HighlightShortcode.php \Drupal\shortcode_basic_tags\Plugin\Shortcode\HighlightShortcode::process()
Performs the shortcode processing.
Parameters
array $attributes: Array of attributes.
string $text: The text string to be processed.
string $langcode: The language code of the text to be filtered. Defaults to LANGCODE_NOT_SPECIFIED.
Return value
string The processed text.
Overrides ShortcodeInterface::process
File
- shortcode_basic_tags/
src/ Plugin/ Shortcode/ HighlightShortcode.php, line 22
Class
- HighlightShortcode
- Wraps content in a div with class highlight.
Namespace
Drupal\shortcode_basic_tags\Plugin\ShortcodeCode
public function process(array $attributes, $text, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
// Merge with default attributes.
$attributes = $this
->getAttributes([
'class' => '',
], $attributes);
$class = $this
->addClass($attributes['class'], 'highlight');
return '<span class="' . $class . '">' . $text . '</span>';
}