Removed Immediate.Apis, Added AOT Testing Scripts.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
namespace Htmx.ApiDemo;
|
||||
|
||||
public static class HtmxExtensions
|
||||
{
|
||||
public static void HtmxAwareWriteToBody(
|
||||
this IHtmxComponent component, HttpContext context, string title, string appName, string pageTitle)
|
||||
{
|
||||
// If not a HX-Request, render the component inside main layout
|
||||
if (!context.Request.Headers.ContainsKey("HX-Request"))
|
||||
{
|
||||
var layout = new MainLayout(component, title: title, appName: appName, pageTitle: pageTitle,
|
||||
userName: context.User.Identity?.IsAuthenticated == true ? context.User.Identity.Name : null);
|
||||
|
||||
context.Response.ContentType = "text/html; charset=utf-8";
|
||||
var renderContext = new HtmxRenderContext(context.Response.BodyWriter);
|
||||
layout.Render(renderContext);
|
||||
return;
|
||||
}
|
||||
|
||||
//Else only render the component
|
||||
component.WriteToResponseBody(context);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user