Skip to content

Commit

Permalink
Don't render self-closing tags (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis authored Oct 13, 2018
1 parent 12b608c commit fc87a0b
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 289 deletions.
2 changes: 1 addition & 1 deletion Sources/Html/Elements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ public func script(_ attribs: [Attribute<Tag.Script>], _ content: StaticString)
///
/// - Parameter attribs: Attributes.
public func script(_ attribs: [Attribute<Tag.Script>]) -> Node {
return element("script", attribs, [""])
return element("script", attribs, [])
}

/// The `<script>` element allows authors to include dynamic script and data blocks in their documents. The element does not represent content for the user.
Expand Down
8 changes: 4 additions & 4 deletions Sources/Html/Render.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public func render(_ node: Node) -> String {
return "<!DOCTYPE \(escapeDoctype(string))>"
case let .element(tag, attribs, children):
let renderedAttribs = render(attribs)
guard !children.isEmpty else {
return "<" + tag + renderedAttribs + (voidElements.contains(tag) ? ">" : "/>")
}
return "<" + tag + renderedAttribs + ">" + render(children) + "</" + tag + ">"
let openTag = "<" + tag + renderedAttribs + ">"
return children.isEmpty && voidElements.contains(tag)
? openTag
: openTag + render(children) + "</" + tag + ">"
case let .text(string):
return escapeTextNode(text: string)
case let .raw(string):
Expand Down
Loading

0 comments on commit fc87a0b

Please sign in to comment.