Taxobox tests?

Fragment of a discussion from Talk:Main Page

Thanks for your reply (here and on my main talk page) and the explanations.
i will try first to look around the other existing templates/scripts, and to try to find detailed help pages.

Regards,

Hexasoft (talk)22:22, 29 November 2012

In september, I first write Module:MathRoman with import of template parameters to the end. But now to develope an equivalent of s:fr:Modèle:Auteur, I use a very well structured module, created by another user, Module:Author. The way to import parameters from template is strange but usefull, in the functions "fr" and "en".

Rical (talk)21:24, 3 December 2012

I'm playing with modules (sorry, I generate a lot of changes due to bugs in my code).
You can check user:Hexasoft/test which calls Template:Taxobox-fr which uses Module:Taxobox-fr.

I also started to write a sub-module for all my tools : Module:Taxoboxoutils. It is mostly dedicated to my purpose but I also have some more generic functions such as cuting a string into "text" and "(homonymy)" when given string "text (homonymy)" (usefull to check the real part of the title, i.e. for italic parts of it).
I also find that parameters in modules do have the trailing spaces given in the template call! So I added a cleanup function to remove trailing and leading spaces.
BTW I failed to use "local config = frame.args" and then to read "config.pagename", which is 'nil' in my test. It seems in other templates to be the page name... I replaced it by preprocess("{{PAGENAME}}") but I guess it is not a good way as preprocess() is claimed to be heavy-process stuff.

Regards,

Hexasoft (talk)22:10, 3 December 2012

I created: Uroplatus guentheri and Rosa canina (plante) for testing my infobox template/module (you need my CSS to really see it). These modules are fun! :)

Hexasoft (talk)23:08, 3 December 2012
 

@Hexasoft: I think you can't directly use wiki markup directly in a module (I think it is possible, despite this, but you need to do some extra stuff to do it—you can't generate "foo {{bar}} bazbazbaz" just with return "foo {{tl|bar}} {{#invoke:String|rep|baz|3}}").

The reason I say this is because the section "Returning text" on mw:Extension:Scribunto/Lua reference manual says this:

The module function should usually return a single string; whatever values are returned will be passed through tostring() and then concatenated with no separator. This string is incorporated into the wikitext as the result of the {{#invoke:}}.
At this point in the page parse, templates have already been expanded, parser functions and extension tags have already been processed, and pre-save transforms (e.g. signature tilde expansion and the pipe trick) have already happened. Therefore the module cannot use these features in its output text. For example, if a module returns "Hello, [[world]]! {{welcome}}", the page will read "Hello, world! {{welcome}}".
On the other hand, subst is handled at an earlier stage of processing, so with {{subst:#invoke:}} only other attempted substitutions will be processed. Since the failed substitution will remain in the wikitext, they will then be processed on the next edit. This should generally be avoided.

So, most likely, the code preprocess("{{PAGENAME}}") in a Lua module would continue to be preprocess("{{PAGENAME}}"), instead of compiling to preprocess("pagename").

(The reason I made this reply is because I saw preprocess("{{PAGENAME}}") in Hexasoft's reply that is the 5th reply (including the first reply, which was by Hexasoft) in this thread.)

Lemondoge ( T C )20:38, 2 April 2016