function XBBCodeFilter::render_tag in Extensible BBCode 7
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 ./
xbbcode.filter.inc - Execute the filter on a particular text.
File
- ./
xbbcode.filter.inc, line 134 - The filtering class. This will be instanced for each filter, and then called to process a piece of text.
Class
- XBBCodeFilter
- @file The filtering class. This will be instanced for each filter, and then called to process a piece of text.
Code
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;
}
}