Last modified: 2006-12-27 10:14:09 UTC
It would be cool to have a {{for: }}-ParserFunction, e.g. for the Babel-Templates. At the time there are many Babel-Templates Specified like {{Babel-4}} {{Babel-5}} etc for 4 or 5 language-buttons. Not this could be {{Babel|4| button1|...|button4}}.
Created attachment 2141 [details] Implemented the {{for: }}-function as i guess it's best - well commented I've already implemented the FOR-Function as i guess it's best. The syntax is {{#for: loopcount | text to loop | join-character | initial value | step size }} each parameter can be ommited, but ommiting the first 2 ones won't make any sense. Examples: <wikitext>List of some Years: {{subst:#for: 9 | * [[19$i]] | $n | 10 | 10}}</wikitext> will be <wikitext>* [[1910]] * [[1920]] * [[1930]] * [[1940]] * [[1950]] * [[1960]] * [[1970]] * [[1980]] * [[1990]]</wikitext> $n is a magic string in join-string cause it is not possible to insert a normal new line there. simpler example: Let'c count: {{#for 9 | $i!}} You can also go backwards: {{#for: 9 | Value: $i | $b | 0 | -1}} ($b is another magic thing for >>|<< (vertical bar)) Countdown: {{#for: 10 | $i, || 10 | -1}} '''Lift off!'''
The time order is exponential in the input size. This won't be put in any extension used by Wikimedia.
umm, maybely i do not have understand you right (my english...) but if i did: We could limit the maximal loop-count (maybe to 100 or something like that) or something like that. And i honestly don not think that 100 for-cycles will slow down the while project.. IMHO while MediaWiki should be used by Wikimedia if it's about time order and input size..
Created attachment 2142 [details] Functions showing how we can limit the resources needed by for I've made 3 functions demonstrating how we could limit the resources needed by for. forLimited1() limits the number of loops per {{#for:}} forLimited2() limits the maximum number of loops in general forLimited3() limits the maximum number that {{#for:}} can be used in one document. Of course these limitations could be combined. They are just not necessary for using for with {{subst:}}, but i don't know how to implement this.
(In reply to comment #2) > The time order is exponential in the input size. This won't > be put in any extension used by Wikimedia. Why not making it clientside in javascript?!
*** This bug has been marked as a duplicate of 2357 ***