Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

2.0.0

Compare
Choose a tag to compare
@sahandnayebaziz sahandnayebaziz released this 09 Nov 18:21
· 8 commits to master since this release

November 9th, 2016

Improved

  • Creating a custom tag is easier. The name and isSelfClosing attributes of tag have been changed to computed properties. By default, name takes the name of the subclass and isSelfClosing returns false. To override either, like we do to create the img tag, is simple:
public class img : tag { 
  override public var isSelfClosing: Bool { 
    return true
  } 
}

thank you @Evertt for #6

  • 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..." }

thank you @Evertt for #10

  • Anything that is Renderable now also conforms to CustomStringConvertible so you can print and use tag subclasses and your own Renderable types in String outputs and see them rendered automatically.

thank you @Evertt for #9/#17

  • 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

thank you @Evertt for #9/#18

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" }
    ]}
]

thank you @Evertt for #16