This repository has been archived by the owner on Jun 5, 2019. It is now read-only.
Releases: sahandnayebaziz/Hypertext
Releases · sahandnayebaziz/Hypertext
2.1.1
September 22nd, 2017
Fixed
- Fixed an extension that was adding a
description
property to all types that conformed toRenderable
, instead of just totag
, that was causing duplication in standard types likeString
andInt
thank you @briancprice for #28
2.1.0
January 21st, 2017
Added
- Custom tags now, by default, render their tags with HTML-appropriate hyphenation if given a camel case name.
public class myNewTag: tag {}
myNewTag().render()
// <my-new-tag/>
thank you @stupergenius for #23
2.0.0
November 9th, 2016
Improved
- Creating a custom tag is easier. The
name
andisSelfClosing
attributes oftag
have been changed to computed properties. By default,name
takes the name of the subclass andisSelfClosing
returns false. To override either, like we do to create theimg
tag, is simple:
public class img : tag {
override public var isSelfClosing: Bool {
return true
}
}
- Initializing a tag with both attributes and children is easier. The order of attributes and children has been flipped so that you can set the attributes first and then set the children off the end of the initializer. Initializing a tag with both attributes and children now looks like:
p(["class": "greeting"]) { "Well hello there..." }
- Anything that is
Renderable
now also conforms toCustomStringConvertible
so you can print and usetag
subclasses and your ownRenderable
types in String outputs and see them rendered automatically.
- The
Renderable
protocol's method for rendering formatted, indented HTML has a new signature takes an integer value that lets you specify the number of spaces to use when indenting.
func render(startingWithSpaces: Int, indentingWithSpaces: Int) -> String
Added
- A new class called
doctype
that can be used to render the most common HTML doctypes. To render a doctype:
doctype(.html5).render()
// used in context
let document: Renderable = [
doctype(.html5),
html {[
head {
title { "Hello there" }
},
body { "blabla" }
]}
]