Re: [Wikidata-l] Request for comments: syntax for including data on client wikis (aka how to make infoboxes)
On 05/22/2012 03:16 PM, Nikola Smolenski wrote: I see no reason for creating a new parser function for inclusion of templates. Also, this syntax would not allow a template to draw data from more than one item, which would probably be a requirement in phase3. Rather, I would include a template normally and use a parser function within the template to access the data. So, instead of {{{data}}} there would be {{#data:}}, instead of {{{data.color}}} there would be {{#data:color}}, instead of {{{data.color(ACME_SURVEY_2010)}}} there would be {{#data:color|ref=ACME_SURVEY_2010}} and so on. This could even be simplified further to {{#data:{{{data_item}}}|color}} The syntax is admittedly longer, but would work as-is with alternate parsers such as Parsoid or a generic parser function API in Lua. It would also preserve referential transparency as far as possible, which is good for finer-grained caching. The parser function should be able to override itself by template parameters - I believe it is possible to do this. I'd strongly recommend against any magic like this, as it makes templates even harder to understand and also harder to cache. Gabriel ___ Wikidata-l mailing list Wikidata-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-l
Re: [Wikidata-l] [wikidata-intern] Request for comments: syntax for including data on client wikis (aka how to make infoboxes)
On 05/22/2012 03:49 PM, Daniel Kinzler wrote: On 22.05.2012 15:15, Nikola Smolenski wrote: 2) alternatively, don't pass item from the article to the template at all. Instead, use parser functions for every access to an item property, and specify the item id as a parameter if necessary. That would create a lot of rundundancy and wouldn't allow normal template parameter syntax to be used to access data properties. You could still pass the data item to the template: {{Infobox|di=q556677}} and inside Template:Infobox: {{#data:{{{di}}}|color}} This is admittedly slightly more verbose. On the other hand, It would also work in articles, and supports multiple items in a single template. More importantly (to me), it is familiar to current editors, compatible with alternate parsers (e.g. Parsoid) or a generic Lua - parser function API and makes it easier to implement generic fragment caching. Overall I'd prefer any magic-free and forward-compatible solution even if it comes at the cost of small syntactic inconveniences. Gabriel ___ Wikidata-l mailing list Wikidata-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-l
Re: [Wikidata-l] Request for comments: syntax for including data on client wikis (aka how to make infoboxes)
On 05/22/2012 09:39 PM, Daniel Kinzler wrote: the {{#data-value}} function lets you output all of these parts all at once (or separately, if you like), and lets you control aspects like the format of the output using parameters. If you choose to output multiple parts at once, {{#data-value}} can use its knowledge about the desired HTML form to do this nicely. E.g. span{{#data-value:data.population|show=label,value,timestamp,source,indicators,edit|form=tr}}/span would be rendered as tr tdPopulation/td td523,411/td td2010/td tda href=#src23[1]/a,a href=#src23[2]/a/td tda title=disputed href=...img src=...//a/td td[a title=edit href=...edit/a]/td /tr Its hard to imagine how to achieve this nicely without using parser functions. -- Duesentrieb (talk) 19:37, 22 May 2012 (UTC) An alternative might be to return JSON from the parser function and let a Lua module, some other parser function or even a new templating construct handle the formatting. Gabriel ___ Wikidata-l mailing list Wikidata-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-l