Wikipedia talk:TemplateData/Tutorial: Difference between revisions
Content deleted Content added
Okeyes (WMF) (talk | contribs) →Skeleton TemplateData Generator: awesome! |
Salix alba (talk | contribs) →Skeleton TemplateData Generator: reply to NicoV |
||
Line 117:
== Skeleton TemplateData Generator ==
I've thrown together a [http://singsurf.org/things/TemplateData.php Skeleton TemplateData Generator]. It reads the source of a template and tries to find all the parameters used, using the regexp <code>/\{\{\{[^\{\|\}]+</code> and outputs a skeleton document with all the parameters listed. --[[User:Salix alba|Salix]] ([[User talk:Salix alba|talk]]): 15:16, 25 July 2013 (UTC)
:Interesting: is it possible to call it directly with language and page name to retrieve this skeleton? If it's possible, I will suggest to Ltrlg to add a call to your tool to automatically populate the window of [[User:NicoV/TemplateDataEditor|TemplateDataEditor]]. Or is your code reusable directly in TemplateDataEditor ? --[[User:NicoV|NicoV]] <sup>([[:fr:Discussion Utilisateur:NicoV|Talk on frwiki]])</sup> 17:11, 25 July 2013 (UTC)
:::It should be easy enough to do. Basically all you need to do is read an api call
::::http://en.wikipedia.org/w/index.php?title=Template%3ATaxobox_name&action=raw
:::Do a regexp on the text looking for <nowiki>{{{.*|</nowiki> or <nowiki>{{{.*}</nowiki>. That finds all the parameters used an a bit of array processing does the rest. There is a link to the source code at the bottom of the page. The one bit I'm not sure on is how to read the api call in javascript. You can easily call it directly e.g.
::::http://singsurf.org/things/TemplateData.php?SiteName=en.wikipedia.org&PageName=Template%3ATaxobox_name
:::Its probably better to actually convert the code to javascript and use a direct api call.--[[User:Salix alba|Salix]] ([[User talk:Salix alba|talk]]): 19:31, 25 July 2013 (UTC)
::This is awesome! [[User:Okeyes (WMF)|Okeyes (WMF)]] ([[User talk:Okeyes (WMF)|talk]]) 17:38, 25 July 2013 (UTC)
|