NHaml 2.0 Beta

Posted by Andrew on November 17, 2008

rightly pointed out that requiring NHaml users to pull the source from SVN was just downright lazy. So I finally got around to putting together an actual release: .

With 2.0 we’ve made some substantial changes and improvements and also greatly simplified the API. Here’s a sneak peak of what’s coming:

  • The biggest change by far has been the introduction of pluggable back-end compilers. NHaml templates can now be authored in one of four languages: C# 2, C# 3, Boo and IronRuby.
  • We have greatly simplified our ASP.NET MVC View Engine which now inherits from the framework provided VirtualPathProviderViewEngine.
  • NHaml 2.0 implements the for convenient handling of HTML encoding.
  • We made some major API usability improvements for stand-alone template rendering.

We still have a bunch of stuff on our backlog, some of which we’ll try and squeeze into 2.0 RTM - Hopefully sometime within the next month.

Enjoy and death to angle brackets!


Use this link to trackback from your own site.


Leave a response

  1. Mon, 17 Nov 2008 04:26:30 CST

    I started using it for writing the samples in my book, and I’m really liking it :)
    Too bad the 2 space tab when most of the people use 4 space ones.

  2. AndrewNo Gravatar Mon, 17 Nov 2008 04:48:15 CST

    “…when most of the people use 4 space one”

    Can you prove that statement? :-)

    Seriously, it comes from Ruby where it’s the standard. I’m a 2 guy myself too as it affords more horizontal real estate but is no less readable.

  3. Mon, 17 Nov 2008 04:55:03 CST

    “Can you prove that statement? :-)”

    I use 4 spaces :)
    And most of the projects I worked with used 4 spaces (and if I’m not wrong the default in VS is 4 spaces tab).

    But it’s just a matter of setting VS (or any other editor) to treat .haml files with that settings :)

  4. Mon, 17 Nov 2008 08:21:32 CST

    [...] to VoteNHaml 2.0 Beta (11/16/2008)Sunday, November 16, 2008 from andrewpeters.netNHaml templates can now be authored in one of four [...]

  5. MadsNo Gravatar Mon, 17 Nov 2008 11:25:05 CST

    I use 4 spaces too :)

  6. Igor LoginovNo Gravatar Mon, 17 Nov 2008 15:55:28 CST

    I use 2 spaces despite I have never tried Ruby :-) I don’t like line breaks in the middle of expression. One line - one thought…

  7. AndrewNo Gravatar Mon, 17 Nov 2008 16:36:41 CST

    I’m going to make the indent configurable and even allow you to use tabs!

  8. Tue, 18 Nov 2008 04:28:31 CST

    Configurable indentation for NHaml…

    Configurable indentation for NHaml…

  9. Wed, 19 Nov 2008 10:59:32 CST

    I am currently using C# 3 in my NHaml templates, and I would really like to see what I might be missing by not using Boo or IronRuby. The project SVN repository contains a sample app. using IronRuby, but how about Boo? Are there any public samples of Boo/NHaml templates around?

    It would be particularly interesting to see some kind of comparison, bringing out the special cases where there is an advantage/disadvantage of using a specific language in an NHaml template. Does such comparison exist?

  10. AndrewNo Gravatar Wed, 19 Nov 2008 17:33:01 CST


    There are a bunch of example Boo templates in the unit tests. We’re working on adding a Boo MVC sample too.



  11. raineNo Gravatar Tue, 25 Nov 2008 13:31:24 CST

    “NHaml templates can now be authored in one of four languages: C# 2, C# 3, Boo and IronRuby”

    Can someone direct me towards some instructions on how to setup NHaml for C# 2.0?

  12. AndrewNo Gravatar Tue, 25 Nov 2008 15:55:37 CST


    You can set it on TemplateEngine or from the config file: