Skip to content

jamesgober/dotnet-webkit-collection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

JG WebKit Collection

The web framework layer of the JG .NET ecosystem. Two libraries that handle HTTP routing and template rendering for ASP.NET Core applications.

Packages

Package Description NuGet
JG.WebKit.Router Trie-based HTTP router. Compiled per-route execution chains, static/dynamic/hybrid routing, hot-reload, parameter constraints. NuGet
JG.WebKit.Views Template engine. Compiled delegate rendering, layouts with sections, partials, loops, conditionals, asset helpers. NuGet

How They Work Together

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);
});

Router Features

  • 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

Views Features

  • {{ 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)

Related Projects

Author

James Gober — github.com/jamesgober

About

The JG WebKit framework for .NET 8. Trie-based router with compiled execution chains and a template engine with compiled rendering. The web layer of the JG .NET ecosystem.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors