模块:Dictionary-Entry.lua:修订间差异
来自「荏苒之境」
无编辑摘要 |
无编辑摘要 |
||
第24行: | 第24行: | ||
local view = html.create('div') | local view = html.create('div') | ||
:tag('p'):wikitext(r.Definition):done() | :tag('p'):wikitext(r.Definition):done() | ||
:tag('p'):wikitext(" | :tag('p'):wikitext("来源:[["..r._pageName.."]]"):done() | ||
if r.Category ~= nil and r.Category ~= "" then | if r.Category ~= nil and r.Category ~= "" then |
2025年8月2日 (六) 20:53的版本
此模块的文档可以在模块:Dictionary-Entry.lua/doc创建
local html = mw.html
local cargo = mw.ext.cargo
local dict_views = require("Module:Dictionary-Views.lua")
local DICT_TABLE = dict_views.TABLE
local entry = {}
entry.show = function(frame)
local args = frame.args
local language = args.language
local spelling = args.spelling
local r = cargo.query(DICT_TABLE, "Definition,Category,Etymology,_pageName", {
where = string.format(
[[Language="%s" AND Spelling="%s"]],
language, spelling, tonumber(args.priority))
})[1]
if r == nil then
return "词典条目不存在:"..spelling
end
local view = html.create('div')
:tag('p'):wikitext(r.Definition):done()
:tag('p'):wikitext("来源:[["..r._pageName.."]]"):done()
if r.Category ~= nil and r.Category ~= "" then
view:tag('h2'):wikitext('类别'):done()
:tag('p'):wikitext(r.Category):done()
end
if r.Etymology ~= nil and r.Etymology ~= "" then
view:tag('h2'):wikitext('词源'):done()
:tag('p'):wikitext(r.Etymology):done()
end
return view
end
return entry