mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-09-24 10:49:29 +00:00
Merge "Try to put TemplateData in an existing noinclude at bottom of the page"
This commit is contained in:
commit
a99d959959
|
@ -149,6 +149,7 @@
|
||||||
replaceTemplateData = function ( newTemplateData ) {
|
replaceTemplateData = function ( newTemplateData ) {
|
||||||
var finalOutput,
|
var finalOutput,
|
||||||
fullWikitext = $textbox.val(),
|
fullWikitext = $textbox.val(),
|
||||||
|
endNoIncludeLength = '</noinclude>'.length,
|
||||||
parts = fullWikitext.match(
|
parts = fullWikitext.match(
|
||||||
/<templatedata>([\s\S]*?)<\/templatedata>/i
|
/<templatedata>([\s\S]*?)<\/templatedata>/i
|
||||||
);
|
);
|
||||||
|
@ -161,12 +162,16 @@
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
finalOutput = fullWikitext;
|
finalOutput = fullWikitext;
|
||||||
if ( fullWikitext.substr( -1 ) !== '\n' ) {
|
if ( finalOutput.substr( -1 ) !== '\n' ) {
|
||||||
finalOutput += '\n';
|
finalOutput += '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !isPageSubLevel ) {
|
if ( !isPageSubLevel ) {
|
||||||
finalOutput += '<noinclude>\n';
|
if ( finalOutput.substr( -endNoIncludeLength - 1 ) === '</noinclude>\n' ) {
|
||||||
|
finalOutput = finalOutput.substr( 0, finalOutput.length - endNoIncludeLength - 1 );
|
||||||
|
} else {
|
||||||
|
finalOutput += '<noinclude>\n';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finalOutput += '<templatedata>\n' +
|
finalOutput += '<templatedata>\n' +
|
||||||
newTemplateData +
|
newTemplateData +
|
||||||
|
|
Loading…
Reference in a new issue