The web framework layer of the JG .NET ecosystem. Two libraries that handle HTTP routing and template rendering for ASP.NET Core applications.
| Package | Description | NuGet |
|---|---|---|
| JG.WebKit.Router | Trie-based HTTP router. Compiled per-route execution chains, static/dynamic/hybrid routing, hot-reload, parameter constraints. | |
| JG.WebKit.Views | Template engine. Compiled delegate rendering, layouts with sections, partials, loops, conditionals, asset helpers. |
The router resolves which route matched. The view engine renders the response. They're independent — use the router without views for pure APIs, or views without the router in other contexts.
// Register both
builder.Services.AddWebKitRouter(options => { ... });
builder.Services.AddWebKitViews(options => { ... });
// Use in pipeline
app.UseWebKitRouter();A matched route's handler decides how to respond — JSON, rendered template, redirect, or anything else:
app.MapRoute("GET", "/blog/{slug}", async (ctx, ct) =>
{
var page = await db.GetPageBySlug(ctx.Match.Parameters["slug"]);
var html = await viewEngine.RenderAsync("blog/post", new TemplateContext(page));
return RouteResult.Html(html);
});- Trie-based matching with O(1) average lookup
- Compiled execution chains (not middleware) with short-circuit evaluation
- Static, dynamic (via
IRouteProvider), and hybrid routing - Built-in constraints:
{id:int},{slug},{name:alpha},{file:filename},{code:regex(...)} - Route groups with shared prefixes and chain nodes
- Hot-reload via atomic trie swap
- Per-route metadata for template names, cache TTL, permissions
{{ variable }}with HTML escaping,{{{ raw }}}for trusted content{{> header }},{{> header "dark" }}— WordPress-style partials with variants{{#if}}/{{#elseif}}/{{#else}}with comparison operators{{#each items as item }}with loop index and empty fallback{{#layout "main" }}/{{#section}}/{{#yield}}— layout system{{ asset "css/main.css" }},{{ image "logo.png" }}— configurable asset paths with CDN support- Custom helpers:
{{ date value "format" }},{{ truncate text 200 }} - Three rendering modes: file-based (dev), compiled (production), database-stored (CMS)
- JG .NET Library Collection — The 11 core libraries
- Service Template — Starter project with everything pre-wired
- Essence CMS — CMS built on the full JG ecosystem
James Gober — github.com/jamesgober