Skip to content

Optional concatenation in attribute blocks #347

@TheNeikos

Description

@TheNeikos

I'm using tailwindcss, it uses a lot of classes that are annoying to write in rust/maud: mt-8, space-y-6 etc...

So, I usually resort to write div class="mt-8 space-y-6", and sometimes even

div class={
  "mt-8 etc..."
}

Now, currently maud supports having concatenating multiple strings like this:

div class={
  "mt-8 "
  "space-y-6"
}

(notice the extra space in the first, since no additional space is added here sadly)

Now, I would like to be able to have an optional class in this situation. I did not find a suitable feature in this situation, so I would suggest something akin to this:

let optional_error_classes: Option<String>;

// ...
div class={
  "mt-8 "
  [optional_error_classes]
}

With None simply being handled as "" and the content otherwise.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions