UIElement
public class UIElement
A UIElement works as the wrapper for an HTML element.
-
The element that is returned when the UIElement is parsed.
Declaration
Swift
public var element: Element
-
The opening tag of the element.
Declaration
Swift
public var start: String
-
The closing tag of the element.
Declaration
Swift
public var end: String
-
Create an instance of UIElement that is the element passed in.
Declaration
Swift
public init(element: Element)
Parameters
element
The element that is created by
.parse()
.Return Value
An instance of UIElement with it’s properties initilized with the element passed in.
-
The attributes that are added to the element on parsing.
Declaration
Swift
public var attributes: [String: String] = [:]
-
The elements text.
Declaration
Swift
public private(set)var text: String = ""
-
The elements children.
Declaration
Swift
public private(set)var children: [ElementRenderable] = []
-
Child elements that are added in String format. Note that these elements are added as children first.
Declaration
Swift
public private(set)var rawElements: [String] = []
-
Adds text to an element if it is not an empty element. The text is safety encoded.
Declaration
Swift
public func add(_ text: String)
Parameters
text
The text to add to the element.
-
Adds text to an element if it is not a single tag element. Note that this text is not safety encoded.
Declaration
Swift
public func addRaw(_ text: String)
Parameters
text
The text that will be added to the element. If you want to know more, ask Jon Skeet 🦄.
-
Adds a child element to an element if it is not an empty element.
Declaration
Swift
public func add(_ child: ElementRenderable)
Parameters
child
The element to add to the element.
-
Adds a String to the rawElements array if it is not a single tag element.
Declaration
Swift
public func inject(_ element: String)
Parameters
element
The element that will be added as a child of the current element.
-
Renders Markdown to HTML that gets added as child elements. This method uses
.inject(string)
for adding the elements.Warning
This method uses an incomplete and broken moduel to render the Markdown. This should be fixed in the future, but for now use Vapor’s markdown package.
Declaration
Swift
public func addMarkdown(_ string: String)throws
Parameters
string
The Markdown that will be rendered to HTML.
-
Creates HTML from the current element and all it’s children. This method is deprecated due to bad naming. Use the
render()
method instead.Declaration
Swift
public func parse() -> String
Return Value
The HTML from the current elements and it’s children.
-
Creates HTML from the current element and all it’s children.
Declaration
Swift
public func render() -> String
Return Value
The HTML from the current elements and it’s children.
-
The top level element of the current element. This means
self
.Declaration
Swift
public var topLevelElement: UIElement