You are here

public function BootstrapListGroupShortcode::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/BootstrapListGroupShortcode.php, line 27
Adds shortcodes for all Bootstrap elements.

Class

BootstrapListGroupShortcode
@Shortcode( id = "bs_list_group", token = "list_group", title = @Translation("List Group"), description = @Translation("Bootstrap 3 shortcode"), weight = 50 )

Namespace

Drupal\bs_shortcodes\Plugin\Shortcode

Code

public function process(array $attributes, $content, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
  $attributes = $this
    ->getAttributes(array(
    'linked' => '',
    'xclass' => '',
    'data' => '',
  ), $attributes);
  $class = 'list-group';
  $class .= $attributes['xclass'] ? ' ' . $attributes['xclass'] : '';
  $data_props = _bs_shortcodes_parse_data_attributes($attributes['data']);
  return sprintf('<%1$s class="%2$s"%3$s>%4$s</%1$s>', $attributes['linked'] != '' ? 'div' : 'ul', Html::escape($class), $data_props ? ' ' . $data_props : '', $content);
}