Last modified: 2009-03-17 02:38:00 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 T18340, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 16340 - Provide a #foreach function
Provide a #foreach function
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Normal enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
: need-parsertest, patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-11-14 10:05 UTC by René Kijewski
Modified: 2009-03-17 02:38 UTC (History)
0 users

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


Attachments
patch against r43444 (see comment) (4.65 KB, patch)
2008-11-14 10:05 UTC, René Kijewski
Details

Description René Kijewski 2008-11-14 10:05:20 UTC
Created attachment 5528 [details]
patch against r43444 (see comment)

Hello,

there where many requests for generic loop functions. I don't think that this genericity is really needful, but a function to split a string by a delimiter and do something for each substring would be.
Consider you want to make a wiki list of "a/b/c/d". Currently it is posible to some degree using #titleparts. And it is done already this way, and by likely bad hacks as well ([[Template:Loop]]). It would be much more easy (and I think it'd go easy on resources, too) if you could iterate the parts like that:

{{#foreach:a/b/c/d|/|n|<nowiki />
* {{{n}}} }}

where the first parameter is the string to split, the second is the delimiter and the third is the variable to contain the substrings. The last parameter is the action to be done for each substring.

I wrote a little extension to provide just that. Unfortunately, I don't know how to count the ressources used, so someone had to add this.
Comment 1 Splarka 2009-03-17 02:38:00 UTC
http://www.mediawiki.org/wiki/Extension:ForeachFunction
http://www.mediawiki.org/wiki/Extension:LoopFunctions
http://www.mediawiki.org/wiki/Extension:Loops 

There are at least 3 extensions that do this now. These most likely won't be included in the ParserFunctions extension.

If you want one of these enabled on Wikimedia that would be a separate bug.

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


Navigation
Links