Last modified: 2012-12-08 23:05:10 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 T44126, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 42126 - Fake perfect template expansion by calling into the PHP API
Fake perfect template expansion by calling into the PHP API
Status: RESOLVED FIXED
Product: Parsoid
Classification: Unclassified
token-stream transforms (Other open bugs)
unspecified
All All
: Normal enhancement
: ---
Assigned To: Gabriel Wicke
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-11-15 01:19 UTC by Gabriel Wicke
Modified: 2012-12-08 23:05 UTC (History)
3 users (show)

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


Attachments

Description Gabriel Wicke 2012-11-15 01:19:22 UTC
Idea: Use the expandtemplates API to get the preprocessed template source, so that we can fake perfect template expansion even with some parser functions unimplemented.

From Roan's mail:

Per last Friday's discussion, the API has a module that performs
template expansion (preprocessing, technically). This recursively
expands pretty much everything in curly braces, but it doesn't parse
other things and it doesn't run Tidy. I'm not exactly clear on how it
treats double-underscore magic words (like __NOTOC__) or curly brace
magic word (like {{DEFAULTSORT}}); I do know that "variable magic
words" (really parameterless core parser functions) like {{PAGENAME}}
get expanded.

Comments are also stripped, unless this is overridden with
&includecomments=1. The API module also takes a title parameter so it
can expand things like {{PAGENAME}} correctly.

Examples (with &format=phpfm for readability, in practice you'd want
to use &format=json):

Navbox templates on the Winston Churchill article:
https://en.wikipedia.org/w/api.php?action=expandtemplates&text={{Churchill}}%0A{{UKPrimeMinisters}}%0A{{Chancellor%20of%20the%20Exchequer}}%0A{{HomeSecretary}}%0A{{Secretary%20of%20State%20for%20Defence}}%0A{{Presidents%20of%20the%20Board%20of%20Trade}}%0A{{Leader%20of%20the%20House%20of%20Commons}}%0A{{Minister%20of%20Munitions}}%0A{{Fathers%20of%20the%20House}}%0A{{UK%20Conservative%20Party}}%0A{{Churchill%20War%20Ministry}}%0A{{Churchill%20Caretaker%20Ministry}}%0A{{Third%20Churchill%20Ministry}}%0A{{Chamberlain%20War%20Ministry}}%0A{{Cold%20War}}%0A{{Cold%20War%20figures}}%0A{{Charlemagne%20Prize%20recipients}}%0A{{Nobel%20Prize%20in%20Literature%20Laureates%201951-1975}}%0A{{Time%20Persons%20of%20the%20Year|27%E2%80%9350}}&title=Winston_Churchill&format=phpfm

Succession boxes on the Churchill article:
https://en.wikipedia.org/w/api.php?action=expandtemplates&text={{S-start}}
Comment 1 Gabriel Wicke 2012-12-08 23:05:10 UTC
Implemented this about two weeks ago, see localsettings sample file for flag to set.

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


Navigation
Links