Page MenuHomePhabricator

Scribunto frame method for templates or invocations with *correctly* preprocessed arguments
Open, Needs TriagePublicFeature

Description

Feature summary Add a frame method to scribunto to create child frames and process arguments with a limited subset of the preprocessing that frame:preprocess would do.

The subset of frame:preprocess: the parsing that is applied on arg input to module invocations.

An example of this problem:

{{#invoke:test|dump_args|== {{!}} wikitext ==
* to [[wikipedia:HTML|HTML]] conversion
* should ''not'' happen now}}

If a Lua table of the same raw args are passed through frame:preprocess, that becomes:

p.dump_args(frame:newChild{ args = {"== {{!}} wikitext ==\n* to [[wikipedia:HTML|HTML]] conversion\n* should ''not'' happen now"} })
==
 "==| '\"`UNIQ--h-0--QINU`\"' wikitext ==\
* to [[wikipedia:HTML|HTML]] conversion\
* should ''not'' happen now"

If you don't use frame:preprocess none of the argument wikitext is expanded by frame:newChild and that's also wrong to me.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):

  1. Matching behaviour between templates and modules for raw argument tables in parent or grandparent frames.
  2. Unit testing of Scribunto modules

Benefits (why should this be implemented?):

Would make it much easier to test modules and follow the exact output produced from the Scribunto module's input.

Event Timeline

SNDST00M updated the task description. (Show Details)

I don't see any HTML parsing there, only a strip marker marking the header so it can be used for page sections. The strip marker should be there even if you pass the same text to the #invoke (but does not remain in the final page either way).

There is another issue with your code, the first = sign in the input is recognized as a parameter assignment, so you are actually assigning

= {{!}} wikitext ==

to a parameter with an empty name. You should add 1 = in front of the input.