wtf_wikipedia icon indicating copy to clipboard operation
wtf_wikipedia copied to clipboard

Sentence-data in template values

Open Gilbert142 opened this issue 6 years ago • 3 comments

For my specific usecase, a custom wiki has templates that act as infoboxes, yet aren’t named or recognized by wtf_wikipedia as such. This means the only way I have to accessing them is through the templates function. Sadly, for some reason, the templates values are parsed, and all links are trashed and replaced with their aliases instead.

For example, {{some_template|link=[https://google.com google]}} results in the object { “link”: “google” }.

Is there any way to access the original link through the parser? Should template values even be parsed like this if they’re represented by such a basic key/value object?

Gilbert142 avatar Jan 27 '19 01:01 Gilbert142

yes, hi Gilbert, this is a good question. Infoboxes are sometimes called 'pseudo-templates' with extra functionality, but there's no way to cleanly decide which is which. It's been annoying. wtf_wikipedia should try harder to soften this distinction.

We should probably refactor our template parsing to return objects, with methods, like .links(), like elsewhere in the codebase. That would make a lot of sense actually.

I think, for the immediate-future, the only solution is to add your desired templates to this list, which will make them returned as infoboxes. sorry bout this! cheers

spencermountain avatar Jan 28 '19 20:01 spencermountain

We should probably refactor our template parsing to return objects, with methods, like .links(), like elsewhere in the codebase. That would make a lot of sense actually.

Sounds perfect 👍

Gilbert142 avatar Jan 30 '19 14:01 Gilbert142

thought about doing this for v8 but then got scared-off, it was too big of a change.

We still need a proper solution. Haven't figured-out what it is yet. 😕 cheers

spencermountain avatar Mar 12 '20 21:03 spencermountain