Standalone NHaml

Posted by Andrew on April 19, 2008

Quite a few people have asked me how to use NHaml outside of ASP.NET MVC. Here’s how to do it:

1) Create your project and add a reference to MvcContrib.NHamlViewEngine
2) Use code like the following to compile and render a template.

var templateCompiler = new TemplateCompiler();
var viewType = templateCompiler.Compile("MyTemplate.haml");		
var view = (ICompiledView)Activator.CreateInstance(viewType);
 
string output = view.Render();

In this case the haml template is located in the same folder as the application.

As always, a good way to figure this stuff out is to take a look at the unit tests. In this case I copied the code verbatim from the NHaml TestFixtureBase class.

Announcing WPF Elements

Posted by Andrew on April 10, 2008

Today we were proud to announce the release of WPF Elements, a collection of foundational WPF components, missing from the built-in controls that ship with WPF, but no less essential in the toolbox of any self-respecting WPF developer.

The controls, crafted with care by our resident WPF guru and C# MVP, include:

So download the trial and enjoy.