Editing
Module:CargoDeclare
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local util_args = require('Module:ArgsUtil') local util_html = require('Module:HtmlUtil') local util_map = require('Module:MapUtil') local util_table = require('Module:TableUtil') local i18n = require('Module:i18nUtil') local DOC_COLUMNS = { 'index', 'field', 'type', 'desc' } local h = {} local p = {} function p.main(frame) local args = util_args.overwrite() -- doc page arg will be set when the declaring template is being transcluded if util_args.castAsBool(args.doc) then return p.doc(args) end if util_args.castAsBool(args.forgadget) then return p.forGadget(args) end return p.declare(args) end function p.declare(args) i18n.init('CargoDeclare') local tableName = args[1] local cargoFields = h.concatFieldsToArgs(h.getFields(tableName)) return mw.getCurrentFrame():callParserFunction{ name = ('#cargo_declare:_table=%s'):format(tableName), args = cargoFields } end function p.doc(args) i18n.init('CargoDeclare') local tableName = args[1] return h.makeDocTable(h.getFields(tableName)) end function p.forGadget(args) i18n.init('CargoDeclare') local cargoFields = h.getFields(args[1]) return util_table.concat(cargoFields, ';!;!;', h.concatForJson) end function h.getFields(tableName) -- this should be called first thing by every top-level method local args = require('Module:CargoDeclare/' .. tableName) util_map.rowsInPlace(args, h.prepareArgs) return args end function h.prepareArgs(row) -- create any auto-generated description text needed if not row.sep then return end local desc = { row.desc ~= '' and row.desc, row.sep and i18n.default('sepSentence', row.sep) } row.desc = util_table.concat(desc, ' ') end function h.concatFieldsToArgs(fields) util_map.inPlace(fields, h.concatFieldToArg) return fields end function h.concatFieldToArg(field) return ('%s=%s'):format(field.field, field.type) end function h.makeDocTable(fields) local output = mw.html.create('table') :addClass('wikitable') util_map.rowsInPlace(fields, h.formatForDocTable) util_html.printHeaderFromI18n(output, DOC_COLUMNS) util_html.printRowsByList(output, fields, DOC_COLUMNS) return output end function h.formatForDocTable(row) end function h.concatForJson(field) return ('%s:::%s'):format(field.field, field.desc) end return p
Summary:
Please note that all contributions to Porn Base Central may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Porn Base Central:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:CargoDeclare/doc
(
view source
)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Upload file
Special pages
Page information