Mediawiki Scribunto can't split page by slash

81 Views Asked by At

I have a Scribunto module that is supposed to format sub pages using more indented bullets:

local p = {} --p stands for package

function p.subpage_bullets( frame )
    local page = frame.args.page
    local parts = mw.text.split( page, "/", true )
    return string.rep("*", #parts) .. " " ..  parts[#parts] 
end

return p

This works as expected in the debug console.

=p.subpage_bullets(mw.getCurrentFrame():newChild{title="whatever",args={["page"]="Foo/Bar"}}) 
** Bar

I'm using it from DPL like so:

{{#dpl:
format=,{{#invoke:Helpers|subpage_bullets|page=%PAGE%}},<br />
|ordermethod=none
|namespace= {{NAMESPACE}}
}}

The result is that the pages are not indented. So a page Foo/Bar returns * Foo/Bar instead of the expected ** Bar.

Why is it not working? I tried replacing "/" in the split with "%2f"/"%2F", which didn't change the result.

Another related question is that the bullets are rendered as * and not interpreted as wikitext so not rendered as an actual bullet.

0

There are 0 best solutions below