Merge "Try to put TemplateData in an existing noinclude at bottom of the page"

This commit is contained in:
jenkins-bot 2016-01-25 12:11:58 +00:00 committed by Gerrit Code Review
commit a99d959959

View file

@ -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 +