Argument Defaults

Asteracea provides multiple ways to make working with optional arguments easier.

Like in for example TypeScript, you can specify default parameters for constructor and render arguments:

fn main() {
asteracea::component! {
    // This will be improved on in the next chapter.
    class: Option<&'bump str> = None,

    .class? = {class}

asteracea::component! {

    <*Classic> "\n" // Parameter omitted.
    <*Classic .class = {Some("classicist")}>
<DIV class=classicist></DIV>

Default parameter expressions are normal Rust expressions, and are evaluated as needed if the parameter was not specified.