Content deleted Content added
m Archiving 1 discussion(s) from Module talk:WikidataIB) (bot |
Fix Linter errors. ย |
||
(One intermediate revision by one other user not shown) | |||
Line 8:
Since the function already references [[Module:URL]], a much better way to do it would be to just reuse what the Module exports. The block starting with {{code|p.url2}} should be rewritten as:
<
local fmt_url = require([[Module:URL]])._url -- put this near the top
Line 28:
return fmt_url(url or txt) .. (icon and ' ' .. icon or "")
end
</
:
: The module doesn't currently reference [[Module:URL]] and it's preferable to reduce the number of external dependencies, rather than increase them unnecessarily. One of the issues with using {{tl|URL}} which prompted the fork to {{tl|URL2}} was that passing a blank url causes an error message by default in URL, but not in URL2:
Line 507:
<pre>{{#invoke:WikidataIB|url2|url={{url|https://www.portoftyne.co.uk/about-us/history/heritage-sites/heritage-sites}}}}</pre>
::produces
<span><!--span tag inserted here October 2022 to prevent spurious Linter error-->{{#invoke:WikidataIB|url2|url={{url|https://www.portoftyne.co.uk/about-us/history/heritage-sites/heritage-sites}}}}
::which is what we were seeing on [[Swing Bridge, River Tyne]]. I believe it is quite common for this template to be used in infoboxes, so unless there is a reliable way of detecting it, I could not use url2 in the way I was previously. Would it be better if only the value from wikidata were put through url2, and the fallback value just displayed raw? — Martin <small>([[User:MSGJ|MSGJ]] ยท [[User talk:MSGJ|talk]])</small> 21:05, 26 November 2020 (UTC)
::: {{re|MSGJ}} I finally remembered what I'd been doing. The call to ur2 in WikidataIB was the prototype for an alternative function that I developed in [[Module:URL]]. I recommend using [[Template:URL2]]. It uses a lot of the code used by {{t|url}} but doesn't give error messages with a nil input (useful for Wikidata) and can take the output of {{tl|url}} as its input if an editor uses that as the local parameter.
|