diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js b/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js index bf2c9b8fa4..5a37a5f9b8 100644 --- a/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js +++ b/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js @@ -50,17 +50,22 @@ ve.ce.MWTransclusionNode.static.iconWhenInvisible = 'template'; * Get a list of descriptions of template parts in a transclusion node * * @static - * @param {ve.dm.Node} model Node model + * @param {ve.dm.MWTransclusionNode} model Node model * @return {string[]} List of template part descriptions */ ve.ce.MWTransclusionNode.static.getTemplatePartDescriptions = function ( model ) { - var i, len, part, + var i, len, part, title, parts = model.getPartsList(), words = []; for ( i = 0, len = parts.length; i < len; i++ ) { part = parts[ i ]; - if ( part.template ) { + // Ignore parts that are just content + if ( part.templatePage ) { + title = mw.Title.newFromText( part.templatePage ); + words.push( title.getRelativeText( mw.config.get( 'wgNamespaceIds' ).template ) ); + } else if ( part.template ) { + // Not actually a template, but e.g. a parser function words.push( part.template ); } } @@ -73,14 +78,6 @@ ve.ce.MWTransclusionNode.static.getTemplatePartDescriptions = function ( model ) */ ve.ce.MWTransclusionNode.static.getDescription = function ( model ) { return this.getTemplatePartDescriptions( model ) - .map( function ( template ) { - var title = mw.Title.newFromText( template, mw.config.get( 'wgNamespaceIds' ).template ); - if ( title ) { - return title.getRelativeText( mw.config.get( 'wgNamespaceIds' ).template ); - } else { - return template; - } - } ) .join( ve.msg( 'comma-separator' ) ); }; diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js index d45c2844e7..0b6aa7bb97 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js @@ -357,8 +357,8 @@ ve.dm.MWTransclusionNode.prototype.isSingleTemplate = function ( templates ) { } for ( i = 0, len = templates.length; i < len; i++ ) { if ( - partsList[ 0 ].template && - normalizeTitle( partsList[ 0 ].template ) === normalizeTitle( templates[ i ] ) + partsList[ 0 ].templatePage && + partsList[ 0 ].templatePage === normalizeTitle( templates[ i ] ) ) { return true; } @@ -372,18 +372,23 @@ ve.dm.MWTransclusionNode.prototype.isSingleTemplate = function ( templates ) { * @return {Object[]} List of objects with either template or content properties */ ve.dm.MWTransclusionNode.prototype.getPartsList = function () { - var i, len, part, content; + var i, len, href, page, part, content; if ( !this.partsList ) { this.partsList = []; content = this.getAttribute( 'mw' ); for ( i = 0, len = content.parts.length; i < len; i++ ) { part = content.parts[ i ]; - this.partsList.push( - part.template ? - { template: part.template.target.wt } : - { content: part } - ); + if ( part.template ) { + href = part.template.target.href; + page = href ? ve.decodeURIComponentIntoArticleTitle( href.replace( /^(\.+\/)*/, '' ) ) : null; + this.partsList.push( { + template: part.template.target.wt, + templatePage: page + } ); + } else { + this.partsList.push( { content: part } ); + } } }