Compiling templates for .Net

Currently there is a NuGet package for doing this, but it does not work with the latest.

I was looking at using Jurassic, but i have a question. Is there anything special that needs to happen relating to Ember vs just using handlebars by itself?

If I had a nickle for every time I found my answer right after posting.

Ember handlebars is different.

There’s is this library: https://github.com/Myslik/csharp-ember-handlebars (I’ve added a Web API based project as a sample)

You can install via NuGet NuGet Gallery | csharp-ember-handlebars-compiler 1.1.0

There are some incompatibilities with newer versions of templates due to the web tools update in VS. Some templates are referencing alpha libs (which is weird) while this handlebars compiler library uses stable .NET libs.

I’m currently using it with Ember 1.0 RC1 and Data rev12, but I had to do some changes on my version of their repo which I haven’t tested enough so I haven’t submitted yet.

Yes, Ive been using this and that has been my issue is that it doesnt work with the most recent VS stuff so im looking for something that does.

Ok. When that was first created we were using the previous version of everything. I believe it should be updated sometime this week or next week the latest. I still haven’t had the time to properly test my stuff and send any PR for that; and I’m not aware of anyone else who sent. I’m having issues with one of the resources which seems to only accept virtual paths for the template files.

If you could kindly create an issue to report the problems you’re having, it would be cool, and I could send a single PR for all the issues.

Like I said, I’m planning to send PR soon with fixes for issues I’ve encountered.

My original plan was to fix this lib; add this lib to the Ember Web API template and once that’s done, and remove both samples from the repo and direct people to use the template instead.

I’ve noticed that people using this library are taking the sample app as a baseline to their own projects and that’s creating an issue since they’re using stable everything and it all breaks when vs updates their templates or when they copy over to a brand new project.

ok i’ll add an issue.

UPDATE: Looks like Myslik is going to update the package very soon.

I’ve just seen that. I’m having to use his namespace instead of Ember.Handlebars

I’ve just sent this PR. The problem was System.Web.Optimization. For some reason Microsoft decided to ship an alpha version of this assemble in all new templates since the Update 1. So I’ve updated that on both the compiler library and the Web API example, also made some modifications as discussed in issue #9, so a template-name.hbs like this gets compiled into template/name since Windows doesn’t allow us to save files with / in the name.

The PR finally got merged :smile:

Sent a new PR to the Ember Web API Template including pre-compilation

Last on this

The compiler library for .NET was added to the Ember.js SPA/WebAPI Template project and should be available for download sometime soon here. There will be more enhancements to support sub directories under ~/scripts/app/templates/ so we can organize templates per resource instead the current state that forces us to leave all templates in the same directory

This is good news. The subdirectory thing is a must have.

I’ve sub-directory support and made some updates to the sample project. This should be merged at some point later when @myslik have time. As of now, the relevant info is available in the README file in my repo.

I’ve added an HTML Helper (@Html.RenderEmberTemplates()), pretty much the same as the one found in the SPA Template for VS, with one horrible change which will have to be re-factored later.

Next step is to include language support (I have no clue of the best approach here. Not sure how to integrate resx without pain) and update the VS template again.