` Defines a variable
/// - `` Defines preformatted text
-open class Code: Tag {
-
+open class Code: StandardTag {
+
+ override open class var name: String { .init(describing: Code.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Col.swift b/Sources/SwiftHtml/Tags/Col.swift
index 5d29277..6f81460 100644
--- a/Sources/SwiftHtml/Tags/Col.swift
+++ b/Sources/SwiftHtml/Tags/Col.swift
@@ -10,6 +10,7 @@
/// The ` ` tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.
open class Col: EmptyTag {
+ override open class var name: String { .init(describing: Col.self).lowercased() }
}
public extension Col {
diff --git a/Sources/SwiftHtml/Tags/Colgroup.swift b/Sources/SwiftHtml/Tags/Colgroup.swift
index 284ba37..f650119 100644
--- a/Sources/SwiftHtml/Tags/Colgroup.swift
+++ b/Sources/SwiftHtml/Tags/Colgroup.swift
@@ -12,8 +12,9 @@
/// **Note:** The `` tag must be a child of a `` element, after any `` elements and before any ` `, ` `, ` `, and `` elements.
///
/// **Tip:** To define different properties to a column within a ``, use the ` ` tag within the ` ` tag.
-open class Colgroup: Tag {
-
+open class Colgroup: StandardTag {
+
+ override open class var name: String { .init(describing: Colgroup.self).lowercased() }
}
public extension Colgroup {
diff --git a/Sources/SwiftHtml/Tags/Comment.swift b/Sources/SwiftHtml/Tags/Comment.swift
index f6c00bd..6bfae51 100644
--- a/Sources/SwiftHtml/Tags/Comment.swift
+++ b/Sources/SwiftHtml/Tags/Comment.swift
@@ -12,11 +12,9 @@
/// Comments are not displayed in the browsers.
/// You can use comments to explain your code, which can help you when you edit the source code at a later date.
/// This is especially useful if you have a lot of code.
-open class Comment: Tag {
-
- open override class func createNode() -> Node {
- Node(type: .comment)
- }
+open class Comment: CommentTag {
+
+ override open class var name: String { .init(describing: Comment.self).lowercased() }
public init(_ contents: String) {
super.init()
diff --git a/Sources/SwiftHtml/Tags/Data.swift b/Sources/SwiftHtml/Tags/Data.swift
index 40ae330..f231058 100644
--- a/Sources/SwiftHtml/Tags/Data.swift
+++ b/Sources/SwiftHtml/Tags/Data.swift
@@ -10,8 +10,9 @@
/// This element provides both a machine-readable value for data processors, and a human-readable value for rendering in a browser.
///
/// **Tip:** If the content is time- or date-related, use the `` element instead.
-open class Data: Tag {
-
+open class Data: StandardTag {
+
+ override open class var name: String { .init(describing: Data.self).lowercased() }
}
public extension Data {
diff --git a/Sources/SwiftHtml/Tags/Datalist.swift b/Sources/SwiftHtml/Tags/Datalist.swift
index 91c1b81..7d76c41 100644
--- a/Sources/SwiftHtml/Tags/Datalist.swift
+++ b/Sources/SwiftHtml/Tags/Datalist.swift
@@ -10,6 +10,7 @@
/// The `` tag is used to provide an "autocomplete" feature for ` ` elements. Users will see a drop-down list of pre-defined options as they input data.
///
/// The `` element's id attribute must be equal to the ` ` element's list attribute (this binds them together).
-open class Datalist: Tag {
-
+open class Datalist: StandardTag {
+
+ override open class var name: String { .init(describing: Datalist.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Dd.swift b/Sources/SwiftHtml/Tags/Dd.swift
index e4c4edd..8d7bc9e 100644
--- a/Sources/SwiftHtml/Tags/Dd.swift
+++ b/Sources/SwiftHtml/Tags/Dd.swift
@@ -10,6 +10,7 @@
/// The `` tag is used in conjunction with `` (defines a description list) and `` (defines terms/names).
///
/// Inside a ` ` tag you can put paragraphs, line breaks, images, links, lists, etc.
-open class Dd: Tag {
-
+open class Dd: StandardTag {
+
+ override open class var name: String { .init(describing: Dd.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Del.swift b/Sources/SwiftHtml/Tags/Del.swift
index c3555a0..ac3e11d 100644
--- a/Sources/SwiftHtml/Tags/Del.swift
+++ b/Sources/SwiftHtml/Tags/Del.swift
@@ -8,8 +8,9 @@
/// The `` tag defines text that has been deleted from a document.
///
/// Browsers will usually strike a line through deleted text.
-open class Del: Tag {
+open class Del: StandardTag {
+ override open class var name: String { .init(describing: Del.self).lowercased() }
}
public extension Del {
diff --git a/Sources/SwiftHtml/Tags/Details.swift b/Sources/SwiftHtml/Tags/Details.swift
index bd1eebd..771afca 100644
--- a/Sources/SwiftHtml/Tags/Details.swift
+++ b/Sources/SwiftHtml/Tags/Details.swift
@@ -12,8 +12,9 @@
/// Any sort of content can be put inside the `` tag.
///
/// **Tip:** The `` tag is used in conjuction with `` to specify a visible heading for the details.
-open class Details: Tag {
-
+open class Details: StandardTag {
+
+ override open class var name: String { .init(describing: Details.self).lowercased() }
}
public extension Details {
diff --git a/Sources/SwiftHtml/Tags/Dfn.swift b/Sources/SwiftHtml/Tags/Dfn.swift
index 0432541..41d558e 100644
--- a/Sources/SwiftHtml/Tags/Dfn.swift
+++ b/Sources/SwiftHtml/Tags/Dfn.swift
@@ -11,6 +11,7 @@
///
/// The term inside the `` tag can be any of the following:
/// `HTML is the standard markup language for creating web pages.
`
-open class Dfn: Tag {
+open class Dfn: StandardTag {
+ override open class var name: String { .init(describing: Dfn.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Dialog.swift b/Sources/SwiftHtml/Tags/Dialog.swift
index bf9ea95..abd8ca2 100644
--- a/Sources/SwiftHtml/Tags/Dialog.swift
+++ b/Sources/SwiftHtml/Tags/Dialog.swift
@@ -8,8 +8,9 @@
/// The `` tag defines a dialog box or subwindow.
///
/// The `` element makes it easy to create popup dialogs and modals on a web page.
-open class Dialog: Tag {
+open class Dialog: StandardTag {
+ override open class var name: String { .init(describing: Dialog.self).lowercased() }
}
public extension Dialog {
diff --git a/Sources/SwiftHtml/Tags/Div.swift b/Sources/SwiftHtml/Tags/Div.swift
index 765238d..4c129e8 100644
--- a/Sources/SwiftHtml/Tags/Div.swift
+++ b/Sources/SwiftHtml/Tags/Div.swift
@@ -14,8 +14,9 @@
/// Any sort of content can be put inside the `` tag!
///
/// **Note:** By default, browsers always place a line break before and after the `
` element.
-open class Div: Tag {
-
+open class Div: StandardTag {
+
+ override open class var name: String { .init(describing: Div.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Dl.swift b/Sources/SwiftHtml/Tags/Dl.swift
index befb68f..ab1d685 100644
--- a/Sources/SwiftHtml/Tags/Dl.swift
+++ b/Sources/SwiftHtml/Tags/Dl.swift
@@ -8,6 +8,7 @@
/// The `
` tag defines a description list.
///
/// The `` tag is used in conjunction with `` (defines terms/names) and ` ` (describes each term/name).
-open class Dl: Tag {
-
+open class Dl: StandardTag {
+
+ override open class var name: String { .init(describing: Dl.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Dt.swift b/Sources/SwiftHtml/Tags/Dt.swift
index 793b1cc..76812f1 100644
--- a/Sources/SwiftHtml/Tags/Dt.swift
+++ b/Sources/SwiftHtml/Tags/Dt.swift
@@ -8,6 +8,7 @@
/// The ` ` tag defines a term/name in a description list.
///
/// The `` tag is used in conjunction with ` ` (defines a description list) and `` (describes each term/name).
-open class Dt: Tag {
+open class Dt: StandardTag {
+ override open class var name: String { .init(describing: Dt.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Em.swift b/Sources/SwiftHtml/Tags/Em.swift
index ffb8da3..f40669b 100644
--- a/Sources/SwiftHtml/Tags/Em.swift
+++ b/Sources/SwiftHtml/Tags/Em.swift
@@ -8,6 +8,7 @@
/// The `` tag is used to define emphasized text. The content inside is typically displayed in italic.
///
/// A screen reader will pronounce the words in `` with an emphasis, using verbal stress.
-open class Em: Tag {
-
+open class Em: StandardTag {
+
+ override open class var name: String { .init(describing: Em.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Embed.swift b/Sources/SwiftHtml/Tags/Embed.swift
index e96b60d..33fffea 100644
--- a/Sources/SwiftHtml/Tags/Embed.swift
+++ b/Sources/SwiftHtml/Tags/Embed.swift
@@ -7,10 +7,10 @@
/// The `` tag defines a container for an external resource, such as a web page, a picture, a media player, or a plug-in application.
open class Embed: EmptyTag {
-
+
+ override open class var name: String { .init(describing: Embed.self).lowercased() }
}
-
public extension Embed {
/// Specifies the height of the embedded content
diff --git a/Sources/SwiftHtml/Tags/Fieldset.swift b/Sources/SwiftHtml/Tags/Fieldset.swift
index 3b5ce6b..63976f0 100644
--- a/Sources/SwiftHtml/Tags/Fieldset.swift
+++ b/Sources/SwiftHtml/Tags/Fieldset.swift
@@ -8,8 +8,9 @@
/// The `` tag is used to group related elements in a form.
///
/// The `` tag draws a box around the related elements.
-open class Fieldset: Tag {
+open class Fieldset: StandardTag {
+ override open class var name: String { .init(describing: Fieldset.self).lowercased() }
}
public extension Fieldset {
diff --git a/Sources/SwiftHtml/Tags/Figcaption.swift b/Sources/SwiftHtml/Tags/Figcaption.swift
index 294df3b..a1504fe 100644
--- a/Sources/SwiftHtml/Tags/Figcaption.swift
+++ b/Sources/SwiftHtml/Tags/Figcaption.swift
@@ -8,6 +8,7 @@
/// The `` tag defines a caption for a `` element.
///
/// The `` element can be placed as the first or last child of the `` element.
-open class Figcaption: Tag {
+open class Figcaption: StandardTag {
+ override open class var name: String { .init(describing: Figcaption.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Figure.swift b/Sources/SwiftHtml/Tags/Figure.swift
index 1ceea75..cadeeae 100644
--- a/Sources/SwiftHtml/Tags/Figure.swift
+++ b/Sources/SwiftHtml/Tags/Figure.swift
@@ -10,7 +10,8 @@
/// While the content of the `` element is related to the main flow, its position is independent of the main flow, and if removed it should not affect the flow of the document.
///
/// **Tip:** The `` element is used to add a caption for the `` element.
-open class Figure: Tag {
-
+open class Figure: StandardTag {
+
+ override open class var name: String { .init(describing: Figure.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Footer.swift b/Sources/SwiftHtml/Tags/Footer.swift
index ff37077..d3acd7c 100644
--- a/Sources/SwiftHtml/Tags/Footer.swift
+++ b/Sources/SwiftHtml/Tags/Footer.swift
@@ -16,6 +16,7 @@
/// - back to top links
/// - related documents
/// You can have several `` elements in one document.
-open class Footer: Tag {
+open class Footer: StandardTag {
+ override open class var name: String { .init(describing: Footer.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Form.swift b/Sources/SwiftHtml/Tags/Form.swift
index eccce02..7a1d9ca 100644
--- a/Sources/SwiftHtml/Tags/Form.swift
+++ b/Sources/SwiftHtml/Tags/Form.swift
@@ -18,8 +18,9 @@
/// - ``
/// - ``
/// - ``
-open class Form: Tag {
-
+open class Form: StandardTag {
+
+ override open class var name: String { .init(describing: Form.self).lowercased() }
}
public extension Form {
@@ -48,47 +49,58 @@ public extension Form {
}
/// Specifies the character encodings that are to be used for the form submission
- func acceptCharset(_ value: String) -> Self {
- attribute("accept-charset", value)
+ @discardableResult
+ func acceptCharset(_ value: String?, _ condition: Bool = true) -> Self {
+ attribute("accept-charset", value, condition)
}
/// Specifies where to send the form-data when a form is submitted
- func action(_ value: String?) -> Self {
- attribute("action", value)
+ @discardableResult
+ func action(_ value: String?, _ condition: Bool = true) -> Self {
+ attribute("action", value, condition)
}
/// Specifies whether a form should have autocomplete on or off
- func autocomplete(_ value: Bool = true) -> Self {
- attribute("autocomplete", value ? "on" : "off")
+ @discardableResult
+ func autocomplete(_ value: Bool? = true, _ condition: Bool = true) -> Self {
+ var onOffValue: String?
+ if let value = value { onOffValue = value ? "on" : "off" }
+ return attribute("autocomplete", onOffValue, condition)
}
/// Specifies how the form-data should be encoded when submitting it to the server (only for method="post")
+ @discardableResult
func enctype(_ value: Enctype?, _ condition: Bool = true) -> Self {
attribute("enctype", value?.rawValue, condition)
}
/// Specifies the HTTP method to use when sending form-data
- func method(_ value: Method?) -> Self {
- attribute("method", value?.rawValue)
+ @discardableResult
+ func method(_ value: Method?, _ condition: Bool = true) -> Self {
+ attribute("method", value?.rawValue, condition)
}
/// Specifies the name of a form
- func name(_ value: String) -> Self {
- attribute("name", value)
+ @discardableResult
+ func name(_ value: String?, _ condition: Bool = true) -> Self {
+ attribute("name", value, condition)
}
/// Specifies that the form should not be validated when submitted
+ @discardableResult
func novalidate(_ condition: Bool = true) -> Self {
flagAttribute("novalidate", nil, condition)
}
/// Specifies the relationship between a linked resource and the current document
- func rel(_ value: Rel) -> Self {
- attribute("rel", value.rawValue)
+ @discardableResult
+ func rel(_ value: Rel?, _ condition: Bool = true) -> Self {
+ attribute("rel", value?.rawValue, condition)
}
/// Specifies where to display the response that is received after submitting the form
- func target(_ value: Target) -> Self {
- attribute("target", value.rawValue)
+ @discardableResult
+ func target(_ value: Target?, condition: Bool = true) -> Self {
+ attribute("target", value?.rawValue, condition)
}
}
diff --git a/Sources/SwiftHtml/Tags/H1.swift b/Sources/SwiftHtml/Tags/H1.swift
index 2cb49d3..8f21bb4 100644
--- a/Sources/SwiftHtml/Tags/H1.swift
+++ b/Sources/SwiftHtml/Tags/H1.swift
@@ -11,6 +11,7 @@
///
/// **Note:** Only use one `` per page - this should represent the main heading/subject for the whole page.
/// Also, do not skip heading levels - start with ``, then use ``, and so on.
-open class H1: Tag {
-
+open class H1: StandardTag {
+
+ override open class var name: String { .init(describing: H1.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/H2.swift b/Sources/SwiftHtml/Tags/H2.swift
index c3bd4ad..e9c4934 100644
--- a/Sources/SwiftHtml/Tags/H2.swift
+++ b/Sources/SwiftHtml/Tags/H2.swift
@@ -11,6 +11,7 @@
///
/// **Note:** Only use one `` per page - this should represent the main heading/subject for the whole page.
/// Also, do not skip heading levels - start with ``, then use ``, and so on.
-open class H2: Tag {
+open class H2: StandardTag {
+ override open class var name: String { .init(describing: H2.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/H3.swift b/Sources/SwiftHtml/Tags/H3.swift
index b88bd76..b38d006 100644
--- a/Sources/SwiftHtml/Tags/H3.swift
+++ b/Sources/SwiftHtml/Tags/H3.swift
@@ -11,6 +11,7 @@
///
/// **Note:** Only use one `` per page - this should represent the main heading/subject for the whole page.
/// Also, do not skip heading levels - start with ``, then use ``, and so on.
-open class H3: Tag {
-
+open class H3: StandardTag {
+
+ override open class var name: String { .init(describing: H3.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/H4.swift b/Sources/SwiftHtml/Tags/H4.swift
index d97f980..2cf3b66 100644
--- a/Sources/SwiftHtml/Tags/H4.swift
+++ b/Sources/SwiftHtml/Tags/H4.swift
@@ -11,6 +11,7 @@
///
/// **Note:** Only use one `` per page - this should represent the main heading/subject for the whole page.
/// Also, do not skip heading levels - start with ``, then use ``, and so on.
-open class H4: Tag {
+open class H4: StandardTag {
+ override open class var name: String { .init(describing: H4.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/H5.swift b/Sources/SwiftHtml/Tags/H5.swift
index e337bab..fb5fb92 100644
--- a/Sources/SwiftHtml/Tags/H5.swift
+++ b/Sources/SwiftHtml/Tags/H5.swift
@@ -11,6 +11,7 @@
///
/// **Note:** Only use one `` per page - this should represent the main heading/subject for the whole page.
/// Also, do not skip heading levels - start with ``, then use ``, and so on.
-open class H5: Tag {
+open class H5: StandardTag {
+ override open class var name: String { .init(describing: H5.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/H6.swift b/Sources/SwiftHtml/Tags/H6.swift
index a15b271..7ba4f95 100644
--- a/Sources/SwiftHtml/Tags/H6.swift
+++ b/Sources/SwiftHtml/Tags/H6.swift
@@ -11,6 +11,7 @@
///
/// **Note:** Only use one `` per page - this should represent the main heading/subject for the whole page.
/// Also, do not skip heading levels - start with ``, then use ``, and so on.
-open class H6: Tag {
-
+open class H6: StandardTag {
+
+ override open class var name: String { .init(describing: H6.self).lowercased() }
}
diff --git a/Sources/SwiftHtml/Tags/Head.swift b/Sources/SwiftHtml/Tags/Head.swift
index e6d5ffb..ac56156 100644
--- a/Sources/SwiftHtml/Tags/Head.swift
+++ b/Sources/SwiftHtml/Tags/Head.swift
@@ -20,6 +20,57 @@
/// - ` `
/// - `