dépôts
/
lhc
/
web
/
wiklou.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ebb291c
)
Improve mediaWiki.parser() (which is a very strange name for a function that expands...
author
Roan Kattouw
<catrope@users.mediawiki.org>
Fri, 8 Oct 2010 10:49:32 +0000
(10:49 +0000)
committer
Roan Kattouw
<catrope@users.mediawiki.org>
Fri, 8 Oct 2010 10:49:32 +0000
(10:49 +0000)
resources/mediawiki/mediawiki.js
patch
|
blob
|
history
diff --git
a/resources/mediawiki/mediawiki.js
b/resources/mediawiki/mediawiki.js
index
5b548f9
..
f56adc2
100644
(file)
--- a/
resources/mediawiki/mediawiki.js
+++ b/
resources/mediawiki/mediawiki.js
@@
-175,9
+175,10
@@
window.mediaWiki = new ( function( $ ) {
*/
this.parser = function( text, options ) {
if ( typeof options === 'object' && typeof options.parameters === 'object' ) {
*/
this.parser = function( text, options ) {
if ( typeof options === 'object' && typeof options.parameters === 'object' ) {
- for ( var p = 0; p < options.parameters.length; p++ ) {
- text = text.replace( '\$' + ( parseInt( p ) + 1 ), options.parameters[p] );
- }
+ text = text.replace( /\$(\d+)/g, function( str, match ) {
+ var index = parseInt( match, 10 ) - 1;
+ return index in options.parameters ? options.parameters[index] : '$' + match;
+ } );
}
return text;
};
}
return text;
};