模块:Flexbox:修订间差异
来自「荏苒之境」
// via Wikitext Extension for VSCode |
无编辑摘要 |
||
(未显示同一用户的2个中间版本) | |||
第1行: | 第1行: | ||
local utils_str = require("Module:Utils/String") | |||
local flexbox = {} | local flexbox = {} | ||
第9行: | 第11行: | ||
local item_template = table.concat { | local item_template = table.concat { | ||
'<div style="flex:1 1 0; min-width: | '<div style="flex:1 1 0; ', | ||
min_width ~= "" and "min-width: "..min_width.."; " or "", | |||
' | max_width ~= "" and "max-width: "..max_width.."; " or "", | ||
padding ~= "" and 'padding :'..padding..';">' or ">" | |||
} | } | ||
local t = {'<div style="display:flex; flex-wrap:wrap; ', style, '">'} | local t = {'<div style="display:flex; flex-wrap:wrap; ', style, '">'} | ||
for | for _, arg in ipairs(frame:getParent().args) do | ||
t[#t+1] = item_template | t[#t+1] = item_template | ||
t[#t+1] = | t[#t+1] = utils_str.trim(arg) | ||
t[#t+1] = "</div>" | t[#t+1] = "</div>" | ||
end | end |
2025年8月8日 (五) 18:38的最新版本
此模块的文档可以在模块:Flexbox/doc创建
local utils_str = require("Module:Utils/String")
local flexbox = {}
flexbox.show = function(frame)
local args = frame.args
local style = args.style or ""
local min_width = args.min_width or ""
local max_width = args.max_width or ""
local padding = args.padding or ""
local item_template = table.concat {
'<div style="flex:1 1 0; ',
min_width ~= "" and "min-width: "..min_width.."; " or "",
max_width ~= "" and "max-width: "..max_width.."; " or "",
padding ~= "" and 'padding :'..padding..';">' or ">"
}
local t = {'<div style="display:flex; flex-wrap:wrap; ', style, '">'}
for _, arg in ipairs(frame:getParent().args) do
t[#t+1] = item_template
t[#t+1] = utils_str.trim(arg)
t[#t+1] = "</div>"
end
t[#t+1] = "</div>"
return table.concat(t)
end
return flexbox