quarkiverse / quarkus-renarde

Server-side Web Framework with Qute templating, magic/easier controllers, auth, reverse-routing
Apache License 2.0
78 stars 19 forks source link

Wrong Content-Type header when using fragments #165

Closed gbourant closed 1 year ago

gbourant commented 1 year ago

When the response is an HTML fragment it adds the Content-Type:text/plain; instead of Content-Type:text/html; so the page is not rendered properly.

@Path("/")
public class HelloResource extends io.quarkiverse.renarde.Controller {

    public io.quarkus.qute.TemplateInstance index() {
        return HtmlTemplate.index();
    }

    public io.quarkus.qute.TemplateInstance fragment() {
        return HtmlTemplate.index$fragment();
    }

}
<p style="color:red">from qute index</p>

{#fragment id='fragment' rendered=false}
 <p style="color:red">the fragment</p>
{/fragment}
@CheckedTemplate
public class HtmlTemplate {

    public static native TemplateInstance index();

    public static native TemplateInstance index$fragment();

}
FroMage commented 1 year ago

This sounds like a generic Qute bug, no, @mkouba ? Perhaps because we don't set VARIANTS on the fragments, but only on the template? Then the TemplateResponseFilter won't be able to set the MediaType properly.

mkouba commented 1 year ago

This sounds like a generic Qute bug, no, @mkouba ? Perhaps because we don't set VARIANTS on the fragments, but only on the template? Then the TemplateResponseFilter won't be able to set the MediaType properly.

You're right. The fragments are not fully integrated with resteasy-qute/type-safe templates yet. I'll try to propose a fix this week.

FroMage commented 1 year ago

Great, thanks. Should I open an issue on Quarkus?

mkouba commented 1 year ago

Great, thanks. Should I open an issue on Quarkus?

https://github.com/quarkusio/quarkus/pull/35841 :smile:

FroMage commented 1 year ago

You're too fast for me. Thanks a lot, I'll close this.