diff --git a/components/widget/html/widget_html_abbr.lua b/components/widget/html/widget_html_abbr.lua
deleted file mode 100644
index ee3603b83b8..00000000000
--- a/components/widget/html/widget_html_abbr.lua
+++ /dev/null
@@ -1,28 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Abbr
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Class = require('Module:Class')
-local Logic = require('Module:Logic')
-local Lua = require('Module:Lua')
-
-local WidgetHtml = Lua.import('Module:Widget/Html/Base')
-
----@class WidgetAbbr: WidgetHtmlBase
----@operator call(table): WidgetAbbr
-local Abbr = Class.new(WidgetHtml)
-
----@return Html?
-function Abbr:render()
- if Logic.isEmpty(self.props.title) or Logic.isEmpty(self.props.children) then
- return nil
- end
- self.props.attributes.title = self.props.attributes.title or self.props.title
- return self:renderAs('abbr')
-end
-
-return Abbr
diff --git a/components/widget/html/widget_html_all.lua b/components/widget/html/widget_html_all.lua
index 04670c47e47..1dc56d97e74 100644
--- a/components/widget/html/widget_html_all.lua
+++ b/components/widget/html/widget_html_all.lua
@@ -8,18 +8,66 @@
local Widgets = {}
+local Array = require('Module:Array')
+local Class = require('Module:Class')
local Lua = require('Module:Lua')
+local String = require('Module:StringUtils')
-Widgets.Abbr = Lua.import('Module:Widget/Html/Abbr')
-Widgets.Center = Lua.import('Module:Widget/Html/Center')
-Widgets.Div = Lua.import('Module:Widget/Html/Div')
-Widgets.Fragment = Lua.import('Module:Widget/Html/Fragment')
-Widgets.Li = Lua.import('Module:Widget/Html/Li')
-Widgets.Span = Lua.import('Module:Widget/Html/Span')
-Widgets.Table = Lua.import('Module:Widget/Html/Table')
-Widgets.Td = Lua.import('Module:Widget/Html/Td')
-Widgets.Th = Lua.import('Module:Widget/Html/Th')
-Widgets.Tr = Lua.import('Module:Widget/Html/Tr')
-Widgets.Ul = Lua.import('Module:Widget/Html/Ul')
+local Widget = Lua.import('Module:Widget')
+
+---@param tag? string
+---@return WidgetHtml
+local function createHtmlTag(tag)
+ ---@class WidgetHtml: Widget
+ ---@operator call(table): WidgetHtml
+ local Html = Class.new(Widget)
+ Html.defaultProps = {
+ classes = {},
+ css = {},
+ attributes = {},
+ }
+
+ ---@return Html
+ function Html:render()
+ local htmlNode = mw.html.create(tag)
+
+ htmlNode:addClass(String.nilIfEmpty(table.concat(self.props.classes, ' ')))
+ htmlNode:css(self.props.css)
+ htmlNode:attr(self.props.attributes)
+
+ Array.forEach(self.props.children, function(child)
+ if Class.instanceOf(child, Widget) then
+ ---@cast child Widget
+ child.context = self:_nextContext()
+ htmlNode:node(child:tryMake())
+ else
+ ---@cast child -Widget
+ ---@diagnostic disable-next-line: undefined-field
+ if type(child) == 'table' and not child._build then
+ mw.log('ERROR! Bad child input:' .. mw.dumpObject(self.props.children))
+ -- Erroring here to make it easier to debug
+ -- Otherwise it will fail when the html is built
+ error('Table passed to HtmlBase:renderAs() without _build method')
+ end
+ htmlNode:node(child)
+ end
+ end)
+ return htmlNode
+ end
+
+ return Html
+end
+
+Widgets.Abbr = createHtmlTag('abbr')
+Widgets.Center = createHtmlTag('center')
+Widgets.Div = createHtmlTag('div')
+Widgets.Fragment = createHtmlTag()
+Widgets.Li = createHtmlTag('li')
+Widgets.Span = createHtmlTag('span')
+Widgets.Table = createHtmlTag('table')
+Widgets.Td = createHtmlTag('td')
+Widgets.Th = createHtmlTag('th')
+Widgets.Tr = createHtmlTag('tr')
+Widgets.Ul = createHtmlTag('ul')
return Widgets
diff --git a/components/widget/html/widget_html_base.lua b/components/widget/html/widget_html_base.lua
deleted file mode 100644
index df7896bea6a..00000000000
--- a/components/widget/html/widget_html_base.lua
+++ /dev/null
@@ -1,59 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Base
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Array = require('Module:Array')
-local Class = require('Module:Class')
-local Lua = require('Module:Lua')
-local String = require('Module:StringUtils')
-
-local Widget = Lua.import('Module:Widget')
-
----@class WidgetHtmlBase: Widget
----@operator call(table): WidgetHtmlBase
-local HtmlBase = Class.new(Widget)
-HtmlBase.defaultProps = {
- classes = {},
- css = {},
- attributes = {},
-}
-
----@return Html
-function HtmlBase:render()
- error('HtmlBase:render() must be overridden')
-end
-
----@param tag string?
----@return Html
-function HtmlBase:renderAs(tag)
- local htmlNode = mw.html.create(tag)
-
- htmlNode:addClass(String.nilIfEmpty(table.concat(self.props.classes, ' ')))
- htmlNode:css(self.props.css)
- htmlNode:attr(self.props.attributes)
-
- Array.forEach(self.props.children, function(child)
- if Class.instanceOf(child, Widget) then
- ---@cast child Widget
- child.context = self:_nextContext()
- htmlNode:node(child:tryMake())
- else
- ---@cast child -Widget
- ---@diagnostic disable-next-line: undefined-field
- if type(child) == 'table' and not child._build then
- mw.log('ERROR! Bad child input:' .. mw.dumpObject(self.props.children))
- -- Erroring here to make it easier to debug
- -- Otherwise it will fail when the html is built
- error('Table passed to HtmlBase:renderAs() without _build method')
- end
- htmlNode:node(child)
- end
- end)
- return htmlNode
-end
-
-return HtmlBase
diff --git a/components/widget/html/widget_html_center.lua b/components/widget/html/widget_html_center.lua
deleted file mode 100644
index b091c813f48..00000000000
--- a/components/widget/html/widget_html_center.lua
+++ /dev/null
@@ -1,23 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Center
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Class = require('Module:Class')
-local Lua = require('Module:Lua')
-
-local WidgetHtml = Lua.import('Module:Widget/Html/Base')
-
----@class WidgetCenter: WidgetHtmlBase
----@operator call(table): WidgetCenter
-local Center = Class.new(WidgetHtml)
-
----@return Html
-function Center:render()
- return self:renderAs('center')
-end
-
-return Center
diff --git a/components/widget/html/widget_html_div.lua b/components/widget/html/widget_html_div.lua
deleted file mode 100644
index 5a5d444209e..00000000000
--- a/components/widget/html/widget_html_div.lua
+++ /dev/null
@@ -1,23 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Div
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Class = require('Module:Class')
-local Lua = require('Module:Lua')
-
-local WidgetHtml = Lua.import('Module:Widget/Html/Base')
-
----@class WidgetDiv: WidgetHtmlBase
----@operator call(table): WidgetDiv
-local Div = Class.new(WidgetHtml)
-
----@return Html
-function Div:render()
- return self:renderAs('div')
-end
-
-return Div
diff --git a/components/widget/html/widget_html_fragment.lua b/components/widget/html/widget_html_fragment.lua
deleted file mode 100644
index 3924318b1b1..00000000000
--- a/components/widget/html/widget_html_fragment.lua
+++ /dev/null
@@ -1,23 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Fragment
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Class = require('Module:Class')
-local Lua = require('Module:Lua')
-
-local WidgetHtml = Lua.import('Module:Widget/Html/Base')
-
----@class WidgetHtmlFragment: WidgetHtmlBase
----@operator call(table): WidgetHtmlFragment
-local Fragment = Class.new(WidgetHtml)
-
----@return Html
-function Fragment:render()
- return self:renderAs(nil)
-end
-
-return Fragment
diff --git a/components/widget/html/widget_html_li.lua b/components/widget/html/widget_html_li.lua
deleted file mode 100644
index f7bd6c5875c..00000000000
--- a/components/widget/html/widget_html_li.lua
+++ /dev/null
@@ -1,23 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Li
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Class = require('Module:Class')
-local Lua = require('Module:Lua')
-
-local WidgetHtml = Lua.import('Module:Widget/Html/Base')
-
----@class WidgetLi: WidgetHtmlBase
----@operator call(table): WidgetLi
-local Li = Class.new(WidgetHtml)
-
----@return Html
-function Li:render()
- return self:renderAs('li')
-end
-
-return Li
diff --git a/components/widget/html/widget_html_span.lua b/components/widget/html/widget_html_span.lua
deleted file mode 100644
index a7abecca45f..00000000000
--- a/components/widget/html/widget_html_span.lua
+++ /dev/null
@@ -1,23 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Span
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Class = require('Module:Class')
-local Lua = require('Module:Lua')
-
-local WidgetHtml = Lua.import('Module:Widget/Html/Base')
-
----@class WidgetSpan: WidgetHtmlBase
----@operator call(table): WidgetSpan
-local Span = Class.new(WidgetHtml)
-
----@return Html
-function Span:render()
- return self:renderAs('span')
-end
-
-return Span
diff --git a/components/widget/html/widget_html_table.lua b/components/widget/html/widget_html_table.lua
deleted file mode 100644
index b513d084f07..00000000000
--- a/components/widget/html/widget_html_table.lua
+++ /dev/null
@@ -1,23 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Table
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Class = require('Module:Class')
-local Lua = require('Module:Lua')
-
-local WidgetHtml = Lua.import('Module:Widget/Html/Base')
-
----@class WidgetTable: WidgetHtmlBase
----@operator call(table): WidgetTable
-local Table = Class.new(WidgetHtml)
-
----@return Html
-function Table:render()
- return self:renderAs('table')
-end
-
-return Table
diff --git a/components/widget/html/widget_html_td.lua b/components/widget/html/widget_html_td.lua
deleted file mode 100644
index 2fd79d52ccb..00000000000
--- a/components/widget/html/widget_html_td.lua
+++ /dev/null
@@ -1,23 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Td
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Class = require('Module:Class')
-local Lua = require('Module:Lua')
-
-local WidgetHtml = Lua.import('Module:Widget/Html/Base')
-
----@class WidgetTd: WidgetHtmlBase
----@operator call(table): WidgetTd
-local Td = Class.new(WidgetHtml)
-
----@return Html
-function Td:render()
- return self:renderAs('td')
-end
-
-return Td
diff --git a/components/widget/html/widget_html_th.lua b/components/widget/html/widget_html_th.lua
deleted file mode 100644
index 5fe4c89275e..00000000000
--- a/components/widget/html/widget_html_th.lua
+++ /dev/null
@@ -1,23 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Th
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Class = require('Module:Class')
-local Lua = require('Module:Lua')
-
-local WidgetHtml = Lua.import('Module:Widget/Html/Base')
-
----@class WidgetTh: WidgetHtmlBase
----@operator call(table): WidgetTh
-local Th = Class.new(WidgetHtml)
-
----@return Html
-function Th:render()
- return self:renderAs('th')
-end
-
-return Th
diff --git a/components/widget/html/widget_html_tr.lua b/components/widget/html/widget_html_tr.lua
deleted file mode 100644
index d2b59b47ca2..00000000000
--- a/components/widget/html/widget_html_tr.lua
+++ /dev/null
@@ -1,23 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Tr
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Class = require('Module:Class')
-local Lua = require('Module:Lua')
-
-local WidgetHtml = Lua.import('Module:Widget/Html/Base')
-
----@class WidgetTr: WidgetHtmlBase
----@operator call(table): WidgetTr
-local Tr = Class.new(WidgetHtml)
-
----@return Html
-function Tr:render()
- return self:renderAs('tr')
-end
-
-return Tr
diff --git a/components/widget/html/widget_html_ul.lua b/components/widget/html/widget_html_ul.lua
deleted file mode 100644
index 549012fc20f..00000000000
--- a/components/widget/html/widget_html_ul.lua
+++ /dev/null
@@ -1,23 +0,0 @@
----
--- @Liquipedia
--- wiki=commons
--- page=Module:Widget/Html/Ul
---
--- Please see https://github.com/Liquipedia/Lua-Modules to contribute
---
-
-local Class = require('Module:Class')
-local Lua = require('Module:Lua')
-
-local WidgetHtml = Lua.import('Module:Widget/Html/Base')
-
----@class WidgetUl: WidgetHtmlBase
----@operator call(table): WidgetUl
-local Ul = Class.new(WidgetHtml)
-
----@return Html
-function Ul:render()
- return self:renderAs('ul')
-end
-
-return Ul
diff --git a/components/widget/widget_all.lua b/components/widget/widget_all.lua
index 9d10eb4f3d5..7da1ef7bf0d 100644
--- a/components/widget/widget_all.lua
+++ b/components/widget/widget_all.lua
@@ -33,11 +33,12 @@ Widgets.TableCell = Lua.import('Module:Widget/Table/Cell')
Widgets.DataTable = Lua.import('Module:Widget/Basic/DataTable')
--- Base Html Widgets
-Widgets.Div = Lua.import('Module:Widget/Html/Div')
-Widgets.Span = Lua.import('Module:Widget/Html/Span')
-Widgets.Table = Lua.import('Module:Widget/Html/Table')
-Widgets.Td = Lua.import('Module:Widget/Html/Td')
-Widgets.Th = Lua.import('Module:Widget/Html/Th')
-Widgets.Tr = Lua.import('Module:Widget/Html/Tr')
+local HtmlWidgets = Lua.import('Module:Widget/Html/All')
+Widgets.Div = HtmlWidgets.Div
+Widgets.Span = HtmlWidgets.Span
+Widgets.Table = HtmlWidgets.Table
+Widgets.Td = HtmlWidgets.Td
+Widgets.Th = HtmlWidgets.Th
+Widgets.Tr = HtmlWidgets.Tr
return Widgets