NVelocity 是 Java Velocity 的 C# 移植,CodePlex 維護同步版本。ASP.NET 整合最小範例:
IHttpHandler(NVelocityHandler)。ProcessRequest 中:VelocityEngine → 設定 FILE_RESOURCE_LOADER_PATH 指向 ~/Views → Init(props)。List<City> → VelocityContext.Put("cities", list)。vm 參數決定模板:velocity.MergeTemplate(vm + ".vm", "UTF-8", ctx, Response.Output)。public class City { public int Id { get; set; } public string Name { get; set; } }
請求 /NVelocityHandler.ashx?vm=CityList 即渲染 Views/CityList.vm。