Skip to content
المشاريع

حول

يضيف طرائق امتداد إلى HttpResponse وHttpRequest لتسهيل العمل مع Htmx.

مشاريع أخرى

كيف تُقاس هذه الأرقام

النمو المقاس للنجوم

خلال 24 ساعة
٠
خلال 7 أيام
٠
خلال 15 يومًا
٠
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

htmx.NET

HTMX Logo

Htmx Htmx.TagHelpers

[!IMPORTANT] htmx.NET 2.x targets htmx 4 only. It is a breaking change from the 1.x line (which supports htmx 1.x/2.x). See the Migration guide. Staying on htmx 1/2? Use htmx.NET 1.x and the previous-version docs.

[!NOTE] 2.0.0 is in preview. Install it with --prerelease and kick the tires — then please share feedback on GitHub issues before the stable release.

Server-side ASP.NET Core helpers that make working with htmx from HttpRequest and HttpResponse simpler, plus Tag Helpers for URL generation, htmx-config, and antiforgery.

📖 Full documentation: khalidabuhakmeh.github.io/Htmx.Net

Install

While 2.x is in preview, add --prerelease:

dotnet add package Htmx --prerelease
dotnet add package Htmx.TagHelpers --prerelease

Requires htmx 4 on the client:

<script src="https://unpkg.com/[email protected]/dist/htmx.min.js" defer></script>

Quick start

Detect htmx requests and return a partial instead of a full page:

// in a Razor Page or controller
return Request.IsHtmx()
    ? Partial("_Form", this)
    : Page();

Read typed htmx request headers (the HX-Source element reference, request type, and more):

if (Request.IsHtmx(out var headers))
{
    var source = headers.SourceElement;   // tag#id, e.g. button#save
    var kind   = headers.RequestType;     // Full or Partial
}

Set htmx response headers with a fluent API:

Response.Htmx(h => h
    .PushUrl("/new-url")
    .Retarget("#result")
    .Reswap(HtmxSwap.OuterMorph)
    .WithTrigger("saved", new { id = 42 }));

Tag Helpers — add to _ViewImports.cshtml:

@addTagHelper *, Htmx.TagHelpers

Generate ASP.NET Core URLs straight onto htmx attributes, and configure htmx + antiforgery:

<meta name="htmx-config" includeAspNetAntiforgeryToken="true" defaultSwap="innerHTML" />

<button hx-get hxn-page="Index" hxn-page-handler="Snippet" hx-target="#result">
    Load
</button>
// Program.cs — expose the antiforgery integration script
app.MapHtmxAntiforgeryScript();

Documentation

New to htmx with ASP.NET Core? See the JetBrains guide to getting started with htmx for ASP.NET Core developers.

License

Copyright (c) Khalid Abuhakmeh. Licensed under the MIT License — see License.md.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…