Giter Club home page Giter Club logo

handlebars-net's Introduction

Handlebars.Net

Join the chat at https://gitter.im/james-andrewsmith/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

gitter-badger avatar james-andrewsmith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

handlebars-net's Issues

Upgrade Handlebars Engine

The current version of the handlebars engine is outdated due to some customisations for pre-compiling templates.

Warning on "AMD64". This mismatch may ...

I get this warning when I compile. I'm suprised to see AMD64?

Warning 1 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:....\handlebars.cs.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

Documentation

There currently is a lack of documentation beyond the readme, which itself needs work:

  1. "Working with Browser Sync" example
  2. Including Helpers
  3. Explaining a template provider
  4. Explaining Donut Caching
  5. Included Helpers (Master Templates, Sections etc(
  6. Partial Template Example
  7. WebAPI Notes, Controller Header, Formatters
  8. React component example

Runtime error - Could not load file or assembly 'handlebars.cs, Version=1.0.0.0

I'm getting the error:

Could not load file or assembly 'handlebars.cs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Even though every thing compiles file, I build a windows app, linked to it, added a reference to noesis stuff and it blows the moment I hit any code that uses "Handlbars."

Some questions on partials & JS helpers

Hi @james-andrewsmith ,

I'm thinking about using your library for project and wanted to check a couple things which I wasn't clear on after reading the readme

With your library can I:
• use partials?
• use helpers which execute javascript such as math or string manipulation?
• run other javascript libraries inside a template such as moment.js

Thanks! any insight or examples would be appreciated.

Building and including in a 64bit project

I'm attempting to build this for x64. I'm able to include the DLL in another C# web project. It's recognized by Visual Studio and even builds fine, but when I go to debug the project I receive the following:

Could not load file or assembly 'handlebars.cs' or one of its dependencies. An attempt was made to load a program with an incorrect format. 

=== Pre-bind state information ===
LOG: User = NATHANE3C0\nate
LOG: DisplayName = handlebars.cs
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: handlebars.cs | Domain ID: 7
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/path/to/project/
LOG: Initial PrivatePath = C:\path\to\project\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\path\to\project\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/4155ec72/40475c7e/handlebars.cs.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/4155ec72/40475c7e/handlebars.cs/handlebars.cs.DLL.
LOG: Attempting download of new URL file:///C:/path/to/project/bin/handlebars.cs.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.


[BadImageFormatException: Could not load file or assembly 'handlebars.cs' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly 'handlebars.cs' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +618
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +677

[HttpException (0x80004005): Could not load file or assembly 'handlebars.cs' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090876
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258

Any help would be greatly appreciated.

Thanks,
@nsbingham

Is this project abandoned?

Is this project abandoned? I see no updates in almost a year (despite a clear roadmap) and no responses to issues. @james-andrewsmith what's the status? Are you looking for contributors? Do pass on ownership? What?

Production Template Engine

Currently the "template provider" is setup for "development only" and need to be rebuilt for performance.

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.