Manual talk:Parser functions

Incomplete or incorrect example code
The examples provided do not work on a fresh installation of 1.26.3. One problem is the extension.json file references classes that are not defined.

Syntax Details
"This magicWords array is not optional. If it is omitted, the parser function simply will not work; the will be rendered as though the extension were not installed."

Additionally, the syntax is very important; do not omit the comma at the end of the magicWords array, even if there is only one entry.

Unparsed Input
I know what I'm asking is essentially what tag extensions do, but is there any to specify that input arguments of the callback function should not be parsed? —Sledged (talk) 18:28, 16 September 2007 (UTC)

Change of Defaults in 1.12
It seems that commit 27667 changed the default for noparse and noarg from false to true in some situations. We have a function which returns a wikitext call to a template (for formatting) with a list of named parameters, and found that while it worked as expected in 1.9 it no longer works with recent SVN. Possibly this is a bug. We had to change our functions to ensure that to: return array( $result, 'noparse' => false); whereas previously they just: return $result; Perhaps someone knows if this was an anticipated change... Karora 01:10, 8 January 2008 (UTC)
 * I just got bit by this, too ... initially, I just returned the generated wikitext from my new parser function, and couldn't figure out why it wasn't being parsed correctly (esp. since it makes extensive use of templates), nor why none of the documentation really specified how to trigger the necessary parsing myself. (It's not the same as for tag extensions!)  I've just added a note on this topic to the Manual:Parser functions page.  Paul Lustgarten 14:50, 16 April 2009 (UTC)

Problem with Time parser function
I posted a question on the ParserFunctions help talk page having to do with a problem with time functions when having a 2 digit date. If anyone has a clue of how to fix it, it would be greatly appreciated! (apologies for not having a screen name; I have one on wikipedia I use a lot, but I just came here to try and figure out why the error was occurring in edits I made at wikipedia) Thanks. 24.236.101.233 09:49, 30 December 2008 (UTC)

Determining the output of recursiveTagParse
I'm attempting to determine the output of recursiveTagParse, which I am calling from a parser function. To do so, I'm trying to return the output of recursiveTagParse wrapped in   tags, which I was hoping would show me the rendered HTML. I'm seeing some unexpected behavior. When I do this:

I get this:
 * test

But when I do this:

I get this:
 * test

It's almost like the rendered HTML is being converted back into wikitext. I'm completely lost. Does anyone have any insight on this?

--Csagedy 04:07, 31 October 2011 (UTC)

Function execute on page reload
I followed the example parser function and made an extension that calls a web api for data. The function works great but only executes when the page is saved after editing. Can someone point me in the right direction on how to make the extension/parser function I just built execute when the wiki page is reloaded?
 * call $parser->disableCache in your parser function. Bawolff (talk) 16:55, 29 November 2013 (UTC)

Calling a parser function without parameters
← WORKS ← DOES NOT WORK

So the colon kind of acts like the call syntax 

Parser function called multiple times when saving page
When saving a page, it apparently is parsed multiple times, which naturally runs the parser functions again. I'm storing data into a SQL database, which is quite resource-intensive. I'd like to avoid running the DB storage parts twice for the same time because it also creates duplicate entries. From my experiments, only the first parsing is stored in the cache and served to the visitor. Is there a possibility to find out if an invocation of the parser function will generate output the user will actually see? Clubfan22 (talk) 08:57, 5 September 2016 (UTC)

How to update category based on ifexpr function
I have created a template that uses ifexpr to set 3 category based on the date entered by the wiki editor. The problem is that category section does not update once the date passes to either warning or expired (Parameter accepts date and it changes based on how close or past the date entered by wiki editor. Category only changes if I save it again.....

---

This template should be used to track down time-sensitive information and place KB articles in 3 different categories


 * ( ✓ - YYYY-MM-DD)
 * ( ⚠ - YYYY-MM-DD)
 * ( ✘ - YYYY-MM-DD)

Usage:

Default values

YYYY-MM-DD: Last revision date

NumberOfDaysBeforeWarning: 30 days

Examples: If today was June 1 2017 and last revision was made on the same day...


 *  - It will display as expired
 *  - It will display as on time
 *  - It will display as warning
 *  - It will display as on time (due to shorter number of days before warning)
 *  - It will display as compliant until 30 days have passed

Problematic example
I copied the example and enabled it, and it shows MWException on my website.