Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make curly brace requirement implicit where possible #239

Closed
mitchhentges opened this issue Nov 25, 2020 · 1 comment · Fixed by #242
Closed

Make curly brace requirement implicit where possible #239

mitchhentges opened this issue Nov 25, 2020 · 1 comment · Fixed by #242

Comments

@mitchhentges
Copy link

mitchhentges commented Nov 25, 2020

Hey, thanks for making this library! I'm enjoying it so far :)
Just curious - I've spotted two place where perhaps curly braces can be implicitly assumed, rather than requiring the user to add clutter with them. These two situations are:

Elements without bodies

For example, when handling CSS links:

html! {
    html {
        head {
            link rel="stylesheet" href="/static/resident-smiler.css" {}
        }
    }
}

I feel like, in this case, the {} shouldn't be needed at the end of the link line? Maybe there's a shortcut I'm missing :)

When elements only have [a single line of] text as their child

For example:

html! {
    table {
        tr {
            td { "item 1 "}
            td { "item 2 "}
        }
        tr {
            td { "item 3 "}
            td { "item 4 "}
        }
    }
}

Versus:

html! {
    table {
        tr {
            td "item 1"
            td "item 2"
        }
        tr {
            td "item 3"
            td "item 4"
        }
    }
}

I'm not sure that these are do-able due to parser limitations, but let me know!
Thanks again for the cool declarative HTML library :)

@lambda-fairy
Copy link
Owner

Thanks for the feedback!

Elements without bodies

That should actually be a semicolon:

link rel="stylesheet" href="/static/resident-smiler.css";

In fact, with the {}, Maud will render <link></link> which probably isn't what you want.

Docs-wise, this is mentioned but it's buried in the middle of the section. Maybe if the note on void elements is split into its own section, it'll be harder to miss?

When elements only have [a single line of] text as their child

Yep, this was how it worked originally! But there were strange edge cases and I ended up removing it (#137). I've gotten feedback on this a few times since -- not just you -- but I haven't figured out a good replacement design that addresses the issues noted in that PR.

BTW, it's great that you're enjoying the library! Please loop me in with any other thoughts you might have 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants