Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -175,9 +175,10 @@ |
176 | 176 | */ |
177 | 177 | this.parser = function( text, options ) { |
178 | 178 | if ( typeof options === 'object' && typeof options.parameters === 'object' ) { |
179 | | - for ( var p = 0; p < options.parameters.length; p++ ) { |
180 | | - text = text.replace( '\$' + ( parseInt( p ) + 1 ), options.parameters[p] ); |
181 | | - } |
| 179 | + text = text.replace( /\$(\d+)/g, function( str, match ) { |
| 180 | + var index = parseInt( match, 10 ) - 1; |
| 181 | + return index in options.parameters ? options.parameters[index] : '$' + match; |
| 182 | + } ); |
182 | 183 | } |
183 | 184 | return text; |
184 | 185 | }; |