egil / Htmxor

Supercharges Blazor static server side rendering (SSR) by seamlessly integrating the Htmx.org frontend library.
MIT License
109 stars 12 forks source link

Conditional writing of markup to output #31

Closed egil closed 2 months ago

egil commented 2 months ago

This PR adds the IConditionalOutputComponent type, which influences how the renderer will generate/write markup to the output during a request.

Here are the rules:

  1. If a component does NOT implement IConditionalOutputComponent, nor any of its parents, it will always generate markup.
  2. If a component does NOT implement IConditionalOutputComponent, but a parent component does, then it's closest parent decides whether or not to generate markup.
  3. If a component implements IConditionalOutputComponent, it decides whether or not it should generate markup. It may also decide this for it's children, if they do not implement IConditionalOutputComponent.

This PR also includes a few changes to the default behavior of Htmxor:

  1. If a component does not include a @attribute [HxLayout(typeof(MyOwnHxLayout)], then it will be assigned the HtmxorLayoutComponentBase by default. This component does NOT generate any markup IF it has one or more children that has implements IConditionalOutputComponent.