Page MenuHomePhabricator

Lua templates invoke modules/parser functions from pages that are transcluded as arguments
Closed, InvalidPublic

Description

Example: {{#invoke:String|find|{{:Jurassic Park}}|dinosaur}}

The above invocation doesn't just return the position of the string "dinosaur" within the text of the article Jurassic Park, as one would expect; it also invokes a module (from the film infobox) that italicizes the page title.

There seems to be no way to force the "find" function to treat a transcluded page as a plain text string to be parsed, without invoking modules from it -- <nowiki> and {{#tag:nowiki}} don't work.

Have tested with string and mw.ustring functions; almost certainly appears more broadly.

Event Timeline

Swpb renamed this task from Lua templates invoke modules from pages that are transcluded as arguments to Lua templates invoke modules/parser functions from pages that are transcluded as arguments.Jul 15 2016, 6:21 PM
Anomie removed a project: MediaWiki-extensions-Lua.
Anomie subscribed.

Transclusions always work that way. The expansion of {{:Jurassic Park}} isn't even done inside Scribunto, the parser does that before Scribunto even sees it.

To be able to do something like what you're asking, you'd need:

  • Allowing access to the unparsed wikitext of parameters (which would need a change to the MediaWiki-Parser to make it possible, then a change in Scribunto to make use of it)
  • A variant of frame:preprocess() that ignores side effects when doing the preprocessing.
  • The module to be rewritten to take advantage of this.

Or if you're willing to change the way you pass the parameter to #invoke, you could get away with just the second bullet. If you want those first two things, file separate feature request tasks for them.

Restricted Application added a subscriber: jeblad. · View Herald TranscriptOct 16 2020, 5:28 PM

I know this is super old at this point, but as an aside, i think you are looking for {{#invoke:String|find|{{msgnw::Jurassic Park}}|dinosaur}} or title:getContent() method