function XBBCodeFilter::render_tag in Extensible BBCode 8
Render a single tag.
Parameters
$tag: The complete match object, including its name, content and attributes.
Return value
HTML code to insert in place of the tag and its content.
1 call to XBBCodeFilter::render_tag()
- XBBCodeFilter::process in lib/
Drupal/ xbbcode/ XBBCodeFilter.php - Execute the filter on a particular text.
File
- lib/
Drupal/ xbbcode/ XBBCodeFilter.php, line 143 - Definition of Drupal\xbbcode\XBBCodeFilter.
Class
- XBBCodeFilter
- The filtering class. This will be instanced for each filter, and then called to process a piece of text.
Namespace
Drupal\xbbcodeCode
function render_tag(XBBCodeTagMatch $tag) {
if ($callback = $this->tags[$tag->name]->callback) {
return $callback($tag, $this);
}
else {
$replace['{content}'] = $tag->content;
$replace['{option}'] = $tag->option;
foreach ($tag->attrs as $name => $value) {
$replace['{' . $name . '}'] = $value;
}
$markup = str_replace(array_keys($replace), array_values($replace), $this->tags[$tag->name]->markup);
// Make sure that unset placeholders are replaced with empty strings.
$markup = preg_replace('/{\\w+}/', '', $markup);
return $markup;
}
}