From 227aa3e764e9fdd00a4380500da5661763a8942f Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Sat, 23 Mar 2019 14:01:15 -0400 Subject: [PATCH] Add "template" tag helper (#43) Fixes #38. --- Sources/Html/ChildOf.swift | 4 ++++ Sources/Html/Elements.swift | 4 ++++ Sources/Html/Tag.swift | 1 + Tests/HtmlSnapshotTestingTests/HtmlSnapshotTestingTests.swift | 1 + .../HtmlSnapshotTestingTests/testSnapshots.1.html | 2 ++ 5 files changed, 12 insertions(+) diff --git a/Sources/Html/ChildOf.swift b/Sources/Html/ChildOf.swift index dd9b1ce..61b4ddb 100644 --- a/Sources/Html/ChildOf.swift +++ b/Sources/Html/ChildOf.swift @@ -42,6 +42,10 @@ extension ChildOf { public static func script(attributes: [Attribute] = [], unsafe content: String = "") -> ChildOf { return .init(.script(attributes: attributes, unsafe: content)) } + + public static func template(attributes: [Attribute] = [], _ content: Node...) -> ChildOf { + return .init(.template(attributes: attributes, .fragment(content))) + } } extension ChildOf where Element == Tag.Colgroup { diff --git a/Sources/Html/Elements.swift b/Sources/Html/Elements.swift index 2d84368..7e1463f 100644 --- a/Sources/Html/Elements.swift +++ b/Sources/Html/Elements.swift @@ -730,6 +730,10 @@ extension Node { return .element("table", attributes: attributes, ChildOf.fragment(content).rawValue) } + public static func template(attributes: [Attribute] = [], _ content: Node...) -> Node { + return .element("template", attributes: attributes, .fragment(content)) + } + /// The `