Last modified: 2006-12-27 10:14:09 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T8794, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 6794 - ParserFunction: {{for: }}
ParserFunction: {{for: }}
Status: RESOLVED DUPLICATE of bug 2357
Product: MediaWiki extensions
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Normal enhancement with 2 votes (vote)
: ---
Assigned To: Julian Fleischer
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-07-23 15:05 UTC by Julian Fleischer
Modified: 2006-12-27 10:14 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Implemented the {{for: }}-function as i guess it's best - well commented (6.68 KB, patch)
2006-07-23 15:15 UTC, Julian Fleischer
Details
Functions showing how we can limit the resources needed by for (1.28 KB, text/plain)
2006-07-23 17:03 UTC, Julian Fleischer
Details

Description Julian Fleischer 2006-07-23 15:05:30 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}}.
Comment 1 Julian Fleischer 2006-07-23 15:15:09 UTC
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!'''
Comment 2 Tim Starling 2006-07-23 15:37:07 UTC
The time order is exponential in the input size. This won't 
be put in any extension used by Wikimedia.
Comment 3 Julian Fleischer 2006-07-23 15:50:02 UTC
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..
Comment 4 Julian Fleischer 2006-07-23 17:03:53 UTC
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.
Comment 5 Marco 2006-07-25 16:25:16 UTC
(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?!
Comment 6 Rob Church 2006-12-27 10:14:09 UTC

*** This bug has been marked as a duplicate of 2357 ***

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links