lib/mw/ApiRequest.js
function TemplateRequest(env, title, oldid, opts) {
	ApiRequest.call(this, env, title);
	// IMPORTANT: Set queueKey to the 'title'
	// since TemplateHandler uses it for recording listeners
	this.queueKey = title;
	this.reqType = "Template Fetch";
	opts = opts || {}; // optional extra arguments

	var apiargs = {
		format: 'json',
		// XXX: should use formatversion=2
		action: 'query',
		prop: 'info|revisions',
		rawcontinue: 1,
		// all revision properties which parsoid is interested in.
		rvprop: 'content|ids|timestamp|size|sha1|contentmodel',
		rvslots: 'main',
	};

	if (oldid) {
		this.oldid = oldid;
		apiargs.revids = oldid;
	} else {
		apiargs.titles = title;
	}

	this.requestOptions = {
		method: 'GET',
		followRedirect: true,
		uri: env.conf.wiki.apiURI,
		qs: apiargs,
		timeout: env.conf.parsoid.timeouts.mwApi.srcFetch,
	};

	this.request(this.requestOptions);
}
function TemplateRequest(env, title, oldid, opts) {
	ApiRequest.call(this, env, title);
	// IMPORTANT: Set queueKey to the 'title'
	// since TemplateHandler uses it for recording listeners
	this.queueKey = title;
	this.reqType = "Template Fetch";
	opts = opts || {}; // optional extra arguments

	var apiargs = {
		format: 'json',
		// XXX: should use formatversion=2
		action: 'query',
		prop: 'info|revisions',
		rawcontinue: 1,
		// all revision properties which parsoid is interested in.
		rvprop: 'content|ids|timestamp|size|sha1|contentmodel',
		rvslots: 'main',
	};

	if (oldid) {
		this.oldid = oldid;
		apiargs.revids = oldid;
	} else {
		apiargs.titles = title;
	}

	this.requestOptions = {
		method: 'GET',
		followRedirect: true,
		uri: env.conf.wiki.apiURI,
		qs: apiargs,
		timeout: env.conf.parsoid.timeouts.mwApi.srcFetch,
	};

	this.request(this.requestOptions);
}
function TemplateRequest ( env , title , oldid , opts ) { ApiRequest . call ( this , env , title ) ; // IMPORTANT: Set queueKey to the 'title' // since TemplateHandler uses it for recording listeners this . queueKey = title ; this . reqType = "Template Fetch" ; opts = opts || { } ; // optional extra arguments var apiargs = { format : 'json' , // XXX: should use formatversion=2 action : 'query' , prop : 'info|revisions' , rawcontinue : 1 , // all revision properties which parsoid is interested in. rvprop : 'content|ids|timestamp|size|sha1|contentmodel' , rvslots : 'main' , } ; if ( oldid ) { this . oldid = oldid ; apiargs . revids = oldid ; } else { apiargs . titles = title ; } this . requestOptions = { method : 'GET' , followRedirect : true , uri : env . conf . wiki . apiURI , qs : apiargs , timeout : env . conf . parsoid . timeouts . mwApi . srcFetch , } ; this . request ( this . requestOptions ) ; }
Template fetch request helper class.

@class
@extends ~ApiRequest
@param {MWParserEnvironment} env
@param {string} title The template (or really, page) we should fetch from the wiki.
@param {string} oldid The revision ID you want to get, defaults to "latest revision".
Template fetch request helper class .