xmlet/HtmlFlow

Partial feels upside down

benzen opened this issue · 3 comments

I'm trying to figure out the correct way to use this htmlflow as a replacement for thymleaf.

The partial idea is already adressed here, but it seams to me that the partial are upside down.
Maybe that's just my perception that is out of wack at least in the documentation.

The way I intend to use partial is much closer to what was done with SelectField in the petClinic.
But there it's in a folder called fragment.

What is the distinction you are doing between fragment and partial ? Would be welcome a PR on the documentation of partial ?

I am using the designation fragment or partial for the same idea. Since its inception HtmlFlow uses the designation partial inspired by other libraries such as handlebars (e.g. https://handlebarsjs.com/guide/partials.html) . Later we noticed that Spring call it fragment instead. If I am not wrong, I think that both partial and fragment are different names for the same thing.

Regarding the SelectField in the petClinic. I tried to translate it to the HtmlFlow version of Petclinic and next you have the example of using the SelectField fragment in CreateOrUpdatePetForm:

.dynamic(div -> view.addPartial(SelectField.view, SelectField.DS.of(petTypes, from(pet, p -> p.getType()))))

which is equivalent to the original PetClinic use:

<input th:replace="~{fragments/selectField :: select ('Type', 'type', ${types})}" />

And in PetClinic HtmlFlow version the SelectField is here: https://github.com/xmlet/spring-petclinic/blob/master/src/main/java/org/springframework/samples/petclinic/views/fragments/SelectField.java

Would be welcome a PR on the documentation of partial ?

Certainly. PRs are welcome.

Thanks,
Miguel

Ok. Please star this repository to increase popularity. Thanks