Jump to content

Module talk:Wikitext Parsing: Difference between revisions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Content deleted Content added
Line 4: Line 4:


I am looking for an off-the-shelf method of determining if a template like {{tl|WikiProject Cycling}} lies inside {{tl|WikiProject banner shell}} or [[Module:WikiProject banner/config#L-479|any of its redirects]]. Can this module's ParseTemplates function provide this efficiently? &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 09:05, 2 July 2024 (UTC)
I am looking for an off-the-shelf method of determining if a template like {{tl|WikiProject Cycling}} lies inside {{tl|WikiProject banner shell}} or [[Module:WikiProject banner/config#L-479|any of its redirects]]. Can this module's ParseTemplates function provide this efficiently? &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 09:05, 2 July 2024 (UTC)

:ParseTemplates is not in the best shape last I remember, and it would probably need quite a bit of work to reliably determine something like that in most cases (there's a reason I've marked it as a beta feature, and even that might be a bit generous thinking about it now - really should get back into wikipedia and fix that some day).
:In your specific case, though, I imagine it would work out of the box (though since there's no concept of a "parent" you would explicitly have to check the Children of any WPbs instead). However, due to how it works, ParseTemplates is designed for getting things as right as possible, which is probably overkill (and not very efficient) for what you describe. Might want to consider if there's an alternative solution (though what that would be I'm not sure - A basic <code>:find()</code> on the entirety of WPbs's text if that's available already in your case?). [[User:Aidan9382|Aidan9382]] <sub>([[User talk:Aidan9382|talk]])</sub> 18:51, 2 July 2024 (UTC)

Revision as of 18:51, 2 July 2024

Find out if template is inside another template

I am looking for an off-the-shelf method of determining if a template like {{WikiProject Cycling}} lies inside {{WikiProject banner shell}} or any of its redirects. Can this module's ParseTemplates function provide this efficiently? — Martin (MSGJ · talk) 09:05, 2 July 2024 (UTC)[reply]

ParseTemplates is not in the best shape last I remember, and it would probably need quite a bit of work to reliably determine something like that in most cases (there's a reason I've marked it as a beta feature, and even that might be a bit generous thinking about it now - really should get back into wikipedia and fix that some day).
In your specific case, though, I imagine it would work out of the box (though since there's no concept of a "parent" you would explicitly have to check the Children of any WPbs instead). However, due to how it works, ParseTemplates is designed for getting things as right as possible, which is probably overkill (and not very efficient) for what you describe. Might want to consider if there's an alternative solution (though what that would be I'm not sure - A basic :find() on the entirety of WPbs's text if that's available already in your case?). Aidan9382 (talk) 18:51, 2 July 2024 (UTC)[reply]