Skip to content

Commit

Permalink
Add "template" tag helper (#43)
Browse files Browse the repository at this point in the history
Fixes #38.
  • Loading branch information
stephencelis authored Mar 23, 2019
1 parent cb03c9b commit 227aa3e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/Html/ChildOf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ extension ChildOf {
public static func script(attributes: [Attribute<Tag.Script>] = [], unsafe content: String = "") -> ChildOf {
return .init(.script(attributes: attributes, unsafe: content))
}

public static func template(attributes: [Attribute<Tag.Template>] = [], _ content: Node...) -> ChildOf {
return .init(.template(attributes: attributes, .fragment(content)))
}
}

extension ChildOf where Element == Tag.Colgroup {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Html/Elements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,10 @@ extension Node {
return .element("table", attributes: attributes, ChildOf.fragment(content).rawValue)
}

public static func template(attributes: [Attribute<Tag.Template>] = [], _ content: Node...) -> Node {
return .element("template", attributes: attributes, .fragment(content))
}

/// The `<textarea>` element represents a multiline plain text edit control for the element's raw value. The contents of the control represent the control's default value.
///
/// - Parameters:
Expand Down
1 change: 1 addition & 0 deletions Sources/Html/Tag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public enum Tag {
public enum Table {}
public enum Tbody {}
public enum Td {}
public enum Template {}
public enum Textarea {}
public enum Tfoot {}
public enum Time {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ final class SnapshotTestingTests: SnapshotTestCase {
.td()
)
),
.template(),
.textarea(""),
.time(),
.u(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ <h6>
</td>
</tr>
</table>
<template>
</template>
<textarea>
</textarea>
<time>
Expand Down

0 comments on commit 227aa3e

Please sign in to comment.