A .net wrapper around existing JavaScript implemented within a number of engines to act as a view engine for MVC or WebAPI. Includes a number of tools to speed up development and deployment of front ends.
Allows a completely .NET backend but a templating language which is compatible with client and server rendering, a completely decoupled front-end which can be deployed seamlessly without a single dropped request.
There are a few features from razor which have been implented:
- Sections
- Donut Caching
- Master Template
The Handlebars WebAPI/MVC view engines can be set to skip rendering handlebars and instead return the raw request JSON which is normally passed to the Handlebars Engine for rendering. This command line server combines remote server data/requests with local templates.
This provides a very light development environment, and is useful for allowing frontend devs to work with production data without setting up databases etc.
I highly recommend using this with browser-sync, live-reload is awesome.
There are currently two engines:
-
ClearScriptEngine uses .Net Bindings to the V8 engine directly, this is high performance, threads afe and recommended for production situations.
-
NodeEngine create a node server and makes async requests via HTTP. This is mainly included for Mono compatibility with Flow, allowing it to be cross platform. This is recommended for development only and is used.
using Handlebars;
// Create the template at any point, app startup, or on the fly.
HandleBars.Compile("test", "<div class=\"entry\"><h1>{{title}}</h1><div class=\"body\">{{{body}}}</div></div>");
// Provide the template name and the context object (which is turned into json)
var html = HandleBars.Run("test", new { title = "My New Post", body = "This is my first post!" });
If deploying to Windows Azure in a Web Role see the example project (ExampleAzureWebRole.csproj), managed code requires the install of the VCRedistribute, and copying the JavaScript.NET dependency to the IIS directory. For more info: (http://msdn.microsoft.com/en-us/library/windowsazure/hh694038.aspx)