This also adds the parameter contentmodel=wikitext to the API request.
This ensures that the text is always parsed as wikitext, even with a
title with a different content model like 'MediaWiki:Common.js'.
Change-Id: I29f0c76c3354a8c97b8296224e14341f71726c2f
'jquery.spinner',
'mediawiki.jqueryMsg',
'mediawiki.api',
+ 'mediawiki.api.parse',
'mediawiki.libs.jpegmeta',
'mediawiki.Title',
'mediawiki.util',
$spinner = $.createSpinner().insertAfter( $element );
- ( new mw.Api() ).get( {
- formatversion: 2,
- action: 'parse',
- text: '{{' + template + '}}',
+ ( new mw.Api() ).parse( '{{' + template + '}}', {
title: $( '#wpDestFile' ).val() || 'File:Sample.jpg',
prop: 'text',
pst: true,
},
processResult: function ( result, template, $previewContainer ) {
- this.responseCache[ template ] = result.parse.text;
+ this.responseCache[ template ] = result;
this.showPreview( this.responseCache[ template ], $previewContainer );
},