diff --git a/modules/parser/ext.core.ParserFunctions.js b/modules/parser/ext.core.ParserFunctions.js index 1291748eb9..7ea542fb11 100644 --- a/modules/parser/ext.core.ParserFunctions.js +++ b/modules/parser/ext.core.ParserFunctions.js @@ -72,7 +72,7 @@ ParserFunctions.prototype._switchLookupFallback = function ( kvs, key, dict, cb, } else if ( kv.v.constructor === String ) { if ( kv.v.trim() !== key ) { // Shortcut - continue + continue; } else { return this._switchLookupFallback( kvs.slice(i), key, dict, cb, kv.v ); } @@ -119,14 +119,25 @@ ParserFunctions.prototype['pf_#ifeq'] = function ( token, frame, cb, args ) { if ( args.length < 3 ) { cb( {} ); } else { - if ( args[0].k.trim() === this.env.tokensToString( args[1].v ).trim() ) { - cb( { tokens: ( args[2] && this._rejoinKV( args[2] ) || [] ) } ); + var b = args[1].v; + if ( b.constructor === String ) { + this._ifeq_worker( cb, args, b ); } else { - cb( { tokens: ( args[3] && this._rejoinKV( args[3] ) || [] ) } ); + cb( {async: true} ); + args[1].v.to('text/plain/expanded', this._ifeq_worker.bind( this, cb, args ) ); } } }; +ParserFunctions.prototype._ifeq_worker = function ( cb, args, b ) { + if ( args[0].k.trim() === b.trim() ) { + cb( { tokens: ( args[2] && this._rejoinKV( args[2] ) || [] ) } ); + } else { + cb( { tokens: ( args[3] && this._rejoinKV( args[3] ) || [] ) } ); + } +}; + + ParserFunctions.prototype['pf_#expr'] = function ( token, frame, cb, args ) { var res, target = args[0].k; diff --git a/modules/parser/mediawiki.TokenTransformManager.js b/modules/parser/mediawiki.TokenTransformManager.js index 1696b8b061..b6df711e82 100644 --- a/modules/parser/mediawiki.TokenTransformManager.js +++ b/modules/parser/mediawiki.TokenTransformManager.js @@ -1109,6 +1109,12 @@ Frame.prototype._convertThunk = function ( chunk, format, cb ) { pipeline.addListener( 'end', this.onThunkEvent.bind( this, cacheIt, accum, false, cb ) ); pipeline.process( chunk.concat( [new EOFTk()] ), this.title ); + } else if ( format === 'text/plain/expanded' ) { + // expand, and then convert to string + var self = this; + chunk.to('tokens/x-mediawiki/expanded', function( chunk ) { + cb( self.manager.env.tokensToString( chunk ) ); + }); } else { throw "Frame._convertThunk: Unsupported format " + format; }