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 Parser;
use PPFrame;
use TemplateParser;
use Sanitizer;
class Tabber {
@ -107,11 +108,13 @@ class Tabber {
return sprintf( '[%s]', $tabpanels );
}
return "<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">' . $tabs . '</nav>' .
'<button class="tabber__header__next" aria-hidden="true"></button></header>' .
'<section class="tabber__section">' . $tabpanels . '</section></div>';
$templateParser = new TemplateParser( __DIR__ . '/templates' );
$data = [
'count' => $count,
'html-tabs' => $tabs,
'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>