Merge "Fix mustache template rendering when TOC is rerendered after an edit"

This commit is contained in:
jenkins-bot 2023-01-11 15:31:25 +00:00 committed by Gerrit Code Review
commit 7f4f36c71f
2 changed files with 16 additions and 2 deletions

View file

@ -5,6 +5,8 @@
*/
const templateBody = require( /** @type {string} */ ( './templates/TableOfContents.mustache' ) );
const templateTocLine = require( /** @type {string} */ ( './templates/TableOfContents__line.mustache' ) );
const templatePinnableElementOpen = require( /** @type {string} */ ( './templates/PinnableElement/Open.mustache' ) );
const templatePinnableElementClose = require( /** @type {string} */ ( './templates/PinnableElement/Close.mustache' ) );
/**
* TableOfContents Config object for filling mustache templates
*/
@ -462,12 +464,14 @@ module.exports = function tableOfContents( props ) {
// @ts-ignore
const mustacheCompiler = mw.template.getCompiler( 'mustache' );
const compiledTemplateBody = mustacheCompiler.compile( templateBody );
const compiledTemplateTocLine = mustacheCompiler.compile( templateTocLine );
// Identifier 'TableOfContents__line' is not in camel case
// (template name is 'TableOfContents__line')
const partials = {
TableOfContents__line: compiledTemplateTocLine // eslint-disable-line camelcase
// eslint-disable-next-line camelcase
TableOfContents__line: mustacheCompiler.compile( templateTocLine ),
'PinnableElement/Open': mustacheCompiler.compile( templatePinnableElementOpen ),
'PinnableElement/Close': mustacheCompiler.compile( templatePinnableElementClose )
};
return compiledTemplateBody.render( data, partials ).html();

View file

@ -365,6 +365,16 @@
"VectorTableOfContentsBeginning"
]
},
{
"name": "resources/skins.vector.es6/templates/PinnableElement/Open.mustache",
"file": "includes/templates/PinnableElement/Open.mustache",
"type": "text"
},
{
"name": "resources/skins.vector.es6/templates/PinnableElement/Close.mustache",
"file": "includes/templates/PinnableElement/Close.mustache",
"type": "text"
},
{
"name": "resources/skins.vector.es6/templates/TableOfContents.mustache",
"file": "includes/templates/TableOfContents.mustache",