public function BootstrapNavShortcode::process in Bootstrap 3 shortcodes 8
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
- src/
Plugin/ Shortcode/ BootstrapNavShortcode.php, line 24 - Adds shortcodes for all Bootstrap elements.
Class
- BootstrapNavShortcode
- Plugin annotation @Shortcode( id = "bs_nav", token = "nav", title = @Translation("Nav"), description = @Translation("Bootstrap 3 shortcode"), weight = 50 )
Namespace
Drupal\bs_shortcodes\Plugin\ShortcodeCode
public function process(array $attributes, $content, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
$attributes = $this
->getAttributes(array(
'type' => '',
'stacked' => '',
'justified' => '',
'xclass' => '',
'data' => '',
), $attributes);
$class = 'nav';
$class .= $attributes['type'] ? ' nav-' . $attributes['type'] : ' nav-tabs';
$class .= $attributes['stacked'] != '' ? ' nav-stacked' : '';
$class .= $attributes['justified'] != '' ? ' nav-justified' : '';
$class .= $attributes['xclass'] ? ' ' . $attributes['xclass'] : '';
$data_props = _bs_shortcodes_parse_data_attributes($attributes['data']);
return sprintf('<ul class="%s"%s>%s</ul>', Html::escape($class), $data_props ? ' ' . $data_props : '', $content);
}