Difference between revisions of "Module:URL/doc"

From blackwiki
Jump to navigation Jump to search
blackwiki>FlightTime
(Update)
m (15 revisions imported)
 
(11 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{High-risk|188,600}}
+
{{High-risk|354,000+}}
{{module rating|alpha}}<!-- delete if this is not desirable -->
+
{{module rating|protected}}
  
The module {{BASEPAGENAME}}” contains (specify) available calls that make so and such.
+
This module implements {{tl|URL}} and {{tl|URL2}}. Please see the template page for documentation.
  
== Usage ==
+
== Lua interface ==
 +
The <code>p._url(url, text, msg)</code> function may be used by other Lua modules. It returns a formatted Wikitext for the given URL, made suitable for line wrapping using {{tag|wbr|x}}. It takes the following parameters:
  
&#123;{#invoke:{{BASEPAGENAME}}|''function_name''<!-- fill an actual name -->|}}
+
; url : '''REQUIRED.''' The URL to format.
 +
; text : '''OPTIONAL.''' Display text to put in the Wikitext link. Defaults to a pretty version of the URL.
 +
; msg : '''OPTIONAL.''' String. If content is <samp>false</samp>, <samp>n</samp> or <samp>N</samp>, do not emit a help message (using {{tlx|tlx}}) when URL is not given.
  
== Parameters ==
+
== Example ==
 +
The following module emits a prettified link to log the user out. It will warp correctly to most widths.
 +
<syntaxhighlight lang=lua>
 +
local url = require('Module:URL')._url
 +
local p = {}
  
The text below assumes that functions are declared as
+
p.main = function(frame)
function p.''function_name''( frame )
+
    return url("https://en.wikipedia.org/wiki/Special:UserLogout")
<!-- delete this paragraph, it is indended for the module’s author, not a user -->
+
end
  
* Positional parameters – the value of frame.args[1] is passed after ''function name'' and vertical bar, the value of frame.args[2] is passed after the value of frame.args[1] and vertical bar, and so on.<!-- rewrite the item -->
+
return p
* Named parameters (specify them) – the same ''name''=''value'' syntax as in MediaWiki templates, are accessible inside the function as frame.args["''name''"].<!-- rewrite or delete the item -->
+
</syntaxhighlight>
  
== Examples ==
+
== See also ==
{{Further|Module:{{BASEPAGENAME}}/testcases}}<!-- delete if you do not intend to create the red-linked page -->
+
* {{ml|WikidataIB|url2}}
 
 
{{#invoke: {{BASEPAGENAME}} | url | example.org }}
 

Latest revision as of 17:49, 29 September 2020

  1. REDIRECT Template:High-use

This module implements {{URL}} and {{URL2}}. Please see the template page for documentation.

Lua interface

The p._url(url, text, msg) function may be used by other Lua modules. It returns a formatted Wikitext for the given URL, made suitable for line wrapping using . It takes the following parameters:

url 
REQUIRED. The URL to format.
text 
OPTIONAL. Display text to put in the Wikitext link. Defaults to a pretty version of the URL.
msg 
OPTIONAL. String. If content is false, n or N, do not emit a help message (using {{tlx}}) when URL is not given.

Example

The following module emits a prettified link to log the user out. It will warp correctly to most widths.

local url = require('Module:URL')._url
local p = {}

p.main = function(frame)
    return url("https://en.wikipedia.org/wiki/Special:UserLogout")
end

return p

See also