Help talk:Extension:ParserFunctions

Jump to navigation Jump to search

About this board

Arlo Barnes (talkcontribs)

Although not stated explicitly, I presume that when calculating at a second level of precision the difference between two dates where a leap second has occurred between them, the leap affects the final count. I was wondering if there is a switch to disregard this and calculate as if the leap second had not happened. This would be handy for math relating to the GPS time system (for instance), which does not observe leap seconds.

Reply to "Leap seconds"

How to output html in an #if function?

2
Lwangaman (talkcontribs)

Is there any way to output HTML in the yes / no sections of an {{#if| parser function? In my case I can't use {{tag| because I need to put a closing span tag </span> followed by an opening span tag <span> (with a specific class). Writing the HTML directly doesn't work, and writing as html entities doesn't work...

>> Update: I didn't realize that {{tag| allows you to specify the type parameter, to determine whether it's an opening tag, or closing tag, or self-closing tag, or opening and closing tag.

>> Update 2: I am quite mixed up. I see that {{tag| is a way of outputting a tag for documentation purposes, so that the tag won't be interpreted literally. How do I actually output a real tag that will be interpreted?

>> Update 3: I finally accomplished what I needed by extending a lua module. The specific case was Template:Quote which I imported into my wiki, I wanted to wrap the author in a <span> with a specific class. I saw that the value for author was being output from within a {{Comma separated list}} template which was directly calling Module:Separated entries. So I added a new parameter "span" to the {{Quote}} template which can be set to true, in which case the lua module separated entries will wrap each element of the list with a span tag. I saw that in lua I can either output an html string directly '<span>' .. doListStuff .. '</span>' or use mw.text.tag('span', {}, CONTENTS). In any case I did succeed, however it seems to me that it is much easier to output html from a lua module than it is from within Template transclusions or template parser functions.

Dinoguy1000 (talkcontribs)

It would help to know what you're actually trying to do here. It may be that, whatever you're trying to achieve, you haven't thought of the best way to go about it yet.

Reply to "How to output html in an #if function?"

How to update parsed datas?

3
Dnsbl1 (talkcontribs)

I installed the Comments and VoteNY extension, retrieving number of comments and votes from a page on another page.

But it doesn't seem to update when comments or votes are added with this

{{NUMBEROFVOTESPAGE:page name}}

{{NUMBEROFCOMMENTSPAGE:page name}}

I tried to put $wgParserCacheType = CACHE_NONE;

but it doesn't seem to change much. The number of votes and comments stay.

Any idea?

Dinoguy1000 (talkcontribs)

Completely disabling caching is generally a bad idea. Do the numbers update if you force the page's cache to be cleared (e.g. by editing the page, or by using action=purge)? If so, then you should add a link to purge the page near where the numbers are displayed, with text like "update these counts" (the code [{{fullurl:{{FULLPAGENAME}}|action=purge}} update these counts] can be used as a base for this).

Dnsbl1 (talkcontribs)

I switched to using cache cause the extensions use it to retrieve datas. I tried after a few hours, ?action=purge update the page correctly and the correct number of comments are displayed, thanks for the idea of adding a link on the page.

Reply to "How to update parsed datas?"

English ordinals in {{#time:}}

2
Alex Mashin (talkcontribs)

It seems to me, that the English ordinal suffixes in date formats in {{#time:}} are not supported: {{#time:jS F Y|January 20, 2000}} gives 20S January 2000 rather than 20th January 2000.

Matěj Suchánek (talkcontribs)

I don't see a support for them as well. It's probably worth making a feature request as other languages may also benefit from this. A workaround can be a template like:

{{{1}}}{{#switch: {{#expr: {{{1}}} mod 100 }}
 | 11 | 12 | 13 = th
 | #default = {{#switch: {{#expr: {{{1}}} mod 10 }}
  | 1 = st | 2 = nd | 3 = rd
  | #default = th
 }}
}}
Reply to "English ordinals in {{#time:}}"
There are no older topics