r111371 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111370‎ | r111371 | r111372 >
Date:14:17, 13 February 2012
Author:gwicke
Status:deferred
Tags:
Comment:
Strip trailing newlines from included templates
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/ext.core.TemplateHandler.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/ext.core.TemplateHandler.js
@@ -279,10 +279,15 @@
280280 this.manager.env.dp( 'TemplateHandler._onEnd' + JSON.stringify( tplExpandData.resultTokens ) );
281281 tplExpandData.expandDone = true;
282282 var res = tplExpandData.resultTokens;
283 - // Remove 'end' token from end
284 - if ( res.length && res[res.length - 1].type === 'END' ) {
285 - this.manager.env.dp( 'TemplateHandler, stripping end ' );
 283+ // Strip 'end' tokens and trailing newlines
 284+ var l = res[res.length - 1];
 285+ while ( res.length &&
 286+ ( l.type === 'END' || l.constructor === NlTk )
 287+ )
 288+ {
 289+ this.manager.env.dp( 'TemplateHandler, stripping end or whitespace tokens' );
286290 res.pop();
 291+ l = res[res.length - 1];
287292 }
288293
289294 // Could also encapsulate the template tokens here, if that turns out

Status & tagging log