This project is read-only.

ExpandoObject Support

Jan 21, 2011 at 10:59 PM

First let me say thanks for addressing my other issues. I appreciate the responsiveness.

Another thing I'm looking at is support for ExpandoObjects.  It would be great to be able to do the following:

dynamic model = new ExpandoObject();
model.Name = "Joe";
string template = "Hello @Model.Name!!";
var result = Razor.Parse(template, model);

The Razor Email template blogged about here ( works with ExpandoObjects and the main difference I can tell between it and your source (yes I've been peeking around) is declaring the Model (eg. Model in your TemplateBase<TModel> class) explicitly as dynamic instead of as an object. I actually made the change in your source and got the ExpandoObjects to work, but it broke other things (ie. Anonymous Types) and I haven't had a chance yet to see why. I apologize if I'm getting a bit too involved, but your library is pretty much what I'm looking for and I'm really enjoying playing with it and seeing what it can do.

Jan 22, 2011 at 12:06 AM

I was just experimenting with ExpandoObject.  It's quite possible that all it needs is the ability to generate TemplateBase<dynamic> when it is generating a typename with an ExpandoObject for a model. From my initial tests this works well. I'll experiment a bit more before a commit a change.