Giter Site home page Giter Site logo

gitter-badger / handlebars-net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from james-andrewsmith/handlebars-net

0.0 1.0 0.0 29.91 MB

Compile & execute handlebars.js templates from within .NET, allowing the use of the same templates in client & server side rendering.

License: Apache License 2.0

C# 30.33% JavaScript 63.17% CSS 6.38% ASP 0.02% Handlebars 0.11%

handlebars-net's Introduction

Handlebars.Net

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.

Why

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.

Additional Features

There are a few features from razor which have been implented:

  • Sections
  • Donut Caching
  • Master Template

Proxy

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.

Engines

There are currently two engines:

  1. ClearScriptEngine uses .Net Bindings to the V8 engine directly, this is high performance, threads afe and recommended for production situations.

  2. 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.

Usage


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

Azure

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)

handlebars-net's People

Contributors

james-andrewsmith avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.