$( function() {
	if ( !mw.pageTriage ) {
		mw.pageTriage = {};
	}
	mw.pageTriage.viewUtil = {
		// fetch and compile a template, then return it.
		// args: view, template
		template: function( arg ) {
			apiRequest = {
				'action': 'pagetriagetemplate',
				'view': arg.view,
				'format': 'json'
			};

			var templateText;
			
			if( arg.template instanceof Array ) {
				apiRequest.template = arg.template.join('|');
			} else {
				apiRequest.template = arg.template;
			}
			
			$.ajax( {
				type: 'post',
				url: mw.util.wikiScript( 'api' ),
				data: apiRequest,
				dataType: 'json',
				async: false,
				success: function( result ) {
					if( result.pagetriagetemplate.result == 'success' ) {
						templateText = result.pagetriagetemplate.template;
					}						
				}
			} );

			return _.template( templateText );
		}
	};
} );

$( function() {
	if ( !mw.pageTriage ) {
		mw.pageTriage = {};
	}
	mw.pageTriage.viewUtil = {
		// fetch and compile a template, then return it.
		// args: view, template
		template: function( arg ) {
			apiRequest = {
				'action': 'pagetriagetemplate',
				'view': arg.view,
				'format': 'json'
			};

			var templateText;
			
			if( arg.template instanceof Array ) {
				apiRequest.template = arg.template.join('|');
			} else {
				apiRequest.template = arg.template;
			}
			
			$.ajax( {
				type: 'post',
				url: mw.util.wikiScript( 'api' ),
				data: apiRequest,
				dataType: 'json',
				async: false,
				success: function( result ) {
					if ( result.pagetriagetemplate !== undefined && result.pagetriagetemplate.result === 'success' ) {
						templateText = result.pagetriagetemplate.template;
					}
				}
			} );

			return _.template( templateText );
		}
	};
} );

Make sure some results were returned to avoid error.
Make sure some results were returned to avoid error.

Change-Id: Ic788bd1be6711e8c9475909562514d66c6a26d4c
