Closed lukashermansson closed 6 months ago
Man, you're on a roll! This is really nice.
I was thinking if it would be possible to make the format options an associated type of the CellValue
trait.
trait CellValue {
type RenderOptions: Default = ();
fn render_value(self, options: &Self::RenderOptions) -> impl IntoView;
}
Then in the maco with some more advanced parsing we translate
#[table(format(foo = "%m.%d.%Y", bar = 3))]
to
CellRenderer::RenderOptions {
foo: "%m.%d.%Y",
bar: 3,
}
What do you think? Am I going too far here? 😄
Man, you're on a roll! This is really nice.
I was thinking if it would be possible to make the format options an associated type of the
CellValue
trait.trait CellValue { type RenderOptions: Default = (); fn render_value(self, options: &Self::RenderOptions) -> impl IntoView; }
Then in the maco with some more advanced parsing we translate
#[table(format(foo = "%m.%d.%Y", bar = 3))]
to
CellRenderer::RenderOptions { foo: "%m.%d.%Y", bar: 3, }
What do you think? Am I going too far here? 😄
I love the ideas provided here, I will make an attempt at that behaviour. It will probably have to have a restriction that the type provided as the RenderOptions is a struct with named public fields (as the macro would have to make some assumptions about this)
I will try it out and if i can get it to work nicely I will push what I can come up with. Thanks for the feedback and the nice ideas.
This has me excited! Thanks so much!
I should be able to find some time tomorrow and make a new release.
This in conjunction with the changes in https://github.com/Synphonyte/leptos-struct-table-macro/pull/6 attempts to remove the
chrono
magic built into the macro and instead gets formatting options to theCellValue
trait.This should if merged, allow
time
integration without any macro magic. It also allows implementors ofCellValue
to act on theRenderOptions
collected from the macro.Feels like this pr could still use some polish, but I wanted to get a draft out pretty early as it might make sense to (in case you like the idea) get this out before we cut a new release.