Skip to content

🖥 `DOM.print` method

Compare
Choose a tag to compare
@MihaelIsaev MihaelIsaev released this 31 Mar 17:26
· 17 commits to master since this release

Normally you can't use print inside of the @DOM since it is a function builder which takes DOM elements, it is not regular function

@DOM override var body: DOM.Content {
    // you can't use print statements here, it is not regular function
    // if/else, if let, guard let statements are not like in regular functions
}

But now it is possible to print inside of the @DOM this way

let hello: String? = nil

@DOM override var body: DOM.Content {
    if let hello = self.hello {
        DOM.print("hello is not null: \(hello)")
    } else {
        DOM.print("hello is null")
    }
}