r67220 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67219‎ | r67220 | r67221 >
Date:15:38, 2 June 2010
Author:daniel
Status:deferred
Tags:
Comment:
yet another try at efficient variable substitution
Modified paths:
  • /trunk/extensions/DataTransclusion/DataTransclusionHandler.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DataTransclusion/DataTransclusionHandler.php
@@ -133,18 +133,37 @@
134134 }
135135
136136 static function renderTemplate( $parser, $title, $record ) {
 137+ //XXX: use cached & preparsed template. $template doesn't have the right type, it seems
 138+ /*
 139+ list( $text, $title ) = $parser->getTemplateDom( $title );
 140+ $frame = $parser->getPreprocessor()->newCustomFrame( $record );
 141+ $text = $frame->expand( $template );
 142+ */
 143+
 144+ //XXX: trying another way. but $piece['parts'] needs to be a PPNode. how to do that?
 145+ /*
 146+ $frame = $parser->getPreprocessor()->newCustomFrame( $record );
 147+
 148+ $piece = array();
 149+
 150+ if ( $title->getNamespace() == NS_TEMPLATE ) $n = "";
 151+ else $n = $title->getNsText() . ":";
 152+
 153+ $piece ['title'] = $n . $title->getText();
 154+ $piece['parts'] = $record;
 155+ $piece['lineStart'] = false; //XXX: ugly. can't know here whether the brace was at the start of a line
 156+
 157+ $ret = $parser->braceSubstitution( $piece, $frame );
 158+ $text = $ret[ 'text' ];
 159+ */
 160+
 161+ //dumb and slow, but works
137162 $p = new Article( $title );
138163 if ( !$p->exists() ) return false;
139164
140165 $text = $p->getContent();
141166 $text = $parser->replaceVariables( $text, $record );
142167
143 - //FIXME: use cached & preparsed template. figure out how to...
144 - /*
145 - list( $text, $title ) = $parser->getTemplateDom( $title );
146 - $frame = $parser->getPreprocessor()->newCustomFrame( $record );
147 - $text = $frame->expand( $template );
148 - */
149168 return $text;
150169 }
151170

Status & tagging log