mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-13 17:57:06 +00:00
Fix mustache template rendering when TOC is rerendered after an edit
Bug: T326682
Change-Id: I7e8f5572a33c4440aed5e6e525a48d8abe4a2afb
(cherry picked from commit 5195949674
)
This commit is contained in:
parent
044397180c
commit
cc9cbd96e9
|
@ -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();
|
||||
|
|
10
skin.json
10
skin.json
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue