mirror of
https://github.com/StarCitizenTools/mediawiki-extensions-TabberNeue.git
synced 2024-11-23 16:06:45 +00:00
feat: add support for custom attributes
- Use MW core sanitizer to sanitize attributes to keep feature parity with core sanitizier - Simplify HTML attribute handling Closes: #194, #183
This commit is contained in:
parent
422c60a573
commit
f553e95d0a
|
@ -76,13 +76,21 @@ class Tabber {
|
|||
* @return string HTML
|
||||
*/
|
||||
public static function render( string $input, int $count, array $args, Parser $parser, PPFrame $frame ): string {
|
||||
$arr = explode( '|-|', $input );
|
||||
$data = [
|
||||
'id' => isset( $args['id'] ) ? $args['id'] : "tabber-$count",
|
||||
'class' => isset( $args['class'] ) ? $args['class'] : '',
|
||||
'array-tabs' => []
|
||||
$attr = [
|
||||
'id' => "tabber-$count",
|
||||
'class' => 'tabber tabber--init'
|
||||
];
|
||||
|
||||
foreach( $args as $attribute => $value ) {
|
||||
$attr = Sanitizer::mergeAttributes( $attr, [ $attribute => $value ] );
|
||||
}
|
||||
|
||||
$data = [
|
||||
'array-tabs' => [],
|
||||
'html-attributes' => Sanitizer::safeEncodeTagAttributes( Sanitizer::validateTagAttributes( $attr, 'div' ) )
|
||||
];
|
||||
|
||||
$arr = explode( '|-|', $input );
|
||||
foreach ( $arr as $tab ) {
|
||||
$tabData = self::getTabData( $tab, $count, $parser, $frame );
|
||||
if ( $tabData === [] ) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div id="{{id}}" class='tabber tabber--init {{class}}'>{{!
|
||||
<div {{{html-attributes}}}'>{{!
|
||||
}}<header class="tabber__header">{{!
|
||||
}}<button class="tabber__header__prev" aria-hidden="true"></button>{{!
|
||||
}}<nav class="tabber__tabs" role="tablist">{{!
|
||||
|
|
Loading…
Reference in a new issue