Module:Road data/browsetable: Difference between revisions
Appearance
Content deleted Content added
BrandonXLF (talk | contribs) Fix bugs |
BrandonXLF (talk | contribs) cssText |
||
Line 2: | Line 2: | ||
local getArgs = require('Module:Arguments').getArgs |
local getArgs = require('Module:Arguments').getArgs |
||
function p._browsetable(content) |
function p._browsetable(content, styles) |
||
if not content then return nil end |
if not content then return nil end |
||
local tbl = mw.html.create('table'):addClass('browse-table') |
local tbl = mw.html.create('table'):addClass('browse-table') |
||
tbl:wikitext(content) |
tbl:wikitext(content) |
||
tbl:cssText(styles) |
|||
return mw.getCurrentFrame():extensionTag{ |
return mw.getCurrentFrame():extensionTag{ |
||
Line 15: | Line 16: | ||
function p.browsetable(frame) |
function p.browsetable(frame) |
||
local args = getArgs(frame) |
local args = getArgs(frame) |
||
⚫ | |||
⚫ | |||
end |
end |
||
Revision as of 19:17, 26 July 2024
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This Lua module is used on approximately 18,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
![]() | This module uses TemplateStyles: |
This module exports the functions browsetable
(for use from wikitext) and _browsetable
(for use within Lua). The functions can serve as a container for the output of Module:Road data/browse while also adding padding between multiple instances of Module:Road data/browse.
Example
{{Box|width=20em|padding=8px|
{{#invoke:Road data/browsetable|browsetable|
{{oh browse|previous_type=SR|previous_route=222|route=OH|next_type=OH 1927|next_route=223|next_dab=1927-1930}}
{{mi browse|previous_type=M|previous_route=222|route=MI|next_type=M|next_route=227}}
}}
}}
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p._browsetable(content, styles)
if not content then return nil end
local tbl = mw.html.create('table'):addClass('browse-table')
tbl:wikitext(content)
tbl:cssText(styles)
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Module:Road data/browsetable/styles.css' }
} .. tostring(tbl)
end
function p.browsetable(frame)
local args = getArgs(frame)
return p._browsetable(args[1], args.styles)
end
return p