refactor: convert part of HTML to Mustache

This commit is contained in:
alistair3149 2024-11-16 00:10:15 -05:00 committed by alistair3149
parent bd5738afe8
commit e85d4785b1
2 changed files with 21 additions and 5 deletions

View file

@ -19,6 +19,7 @@ use JsonException;
use MediaWiki\MediaWikiServices; use MediaWiki\MediaWikiServices;
use Parser; use Parser;
use PPFrame; use PPFrame;
use TemplateParser;
use Sanitizer; use Sanitizer;
class Tabber { class Tabber {
@ -107,11 +108,13 @@ class Tabber {
return sprintf( '[%s]', $tabpanels ); return sprintf( '[%s]', $tabpanels );
} }
return "<div id='tabber-$count' class='tabber tabber--init'>" . $templateParser = new TemplateParser( __DIR__ . '/templates' );
'<header class="tabber__header"><button class="tabber__header__prev" aria-hidden="true"></button>' . $data = [
'<nav class="tabber__tabs" role="tablist">' . $tabs . '</nav>' . 'count' => $count,
'<button class="tabber__header__next" aria-hidden="true"></button></header>' . 'html-tabs' => $tabs,
'<section class="tabber__section">' . $tabpanels . '</section></div>'; 'html-tabpanels' => $tabpanels
];
return $templateParser->processTemplate( 'Tabber', $data );
} }
/** /**

View file

@ -0,0 +1,13 @@
{{!
int count Current Tabber count
string html-tabs
string html-tabpanels
}}
<div id="tabber-{{count}}" class='tabber tabber--init'>
<header class="tabber__header">
<button class="tabber__header__prev" aria-hidden="true"></button>
<nav class="tabber__tabs" role="tablist">{{{html-tabs}}}</nav>
<button class="tabber__header__next" aria-hidden="true"></button>
</header>
<section class="tabber__section">{{{html-tabpanels}}}</section>
</div>