- if ( $contextNode->name == 'template' ) {
- # Double-brace expansion
- $bits = $contextNode->splitTemplate();
- if ( $flags & PPFrame::NO_TEMPLATES ) {
- $newIterator = $this->virtualBracketedImplode( '{{', '|', '}}', $bits['title'], $bits['parts'] );
+ $contextName = $contextNode->name;
+ $contextChildren = $contextNode->getRawChildren();
+ } elseif ( is_array( $contextNode ) ) {
+ // Node descriptor array
+ if ( count( $contextNode ) !== 2 ) {
+ throw new MWException( __METHOD__.
+ ': found an array where a node descriptor should be' );
+ }
+ list( $contextName, $contextChildren ) = $contextNode;
+ } else {
+ throw new MWException( __METHOD__ . ': Invalid parameter type' );
+ }
+
+ // Handle node descriptor array or tree object
+ if ( $contextName === false ) {
+ // Not a node, already handled above
+ } elseif ( $contextName[0] === '@' ) {
+ // Attribute: no output
+ } elseif ( $contextName === 'template' ) {
+ # Double-brace expansion
+ $bits = PPNode_Hash_Tree::splitRawTemplate( $contextChildren );
+ if ( $flags & PPFrame::NO_TEMPLATES ) {
+ $newIterator = $this->virtualBracketedImplode(
+ '{{', '|', '}}',
+ $bits['title'],
+ $bits['parts']
+ );
+ } else {
+ $ret = $this->parser->braceSubstitution( $bits, $this );
+ if ( isset( $ret['object'] ) ) {
+ $newIterator = $ret['object'];