I am trying to use Dot Liquid , which is one of the coolest templates for C #. Dot Liquid uses a method to make using templates safe. Here is an explanation page.
Here is an explanation from this wiki:
DotLiquid by default only accepts a limited number of types as parameters to the rendering method, including .NET primitive types (int, float, string, etc.), as well as some collections of types, including IDictionary, IList, and IIndexable (user DotLiquid interface) .
If it supports arbitrary types, then this can lead to methods being unintentionally exposed for template authors. To prevent this, DotLiquid uses Drop objects. Using the droplets approach to disclosing a data object.
The Drop class is just one ILiquidizable implementation and the easiest way to expose objects for DotLiquid templates is to implement ILiquidizable directly
Wiki example:
public class User
{
public string Name { get; set; }
public string Email { get; set; }
}
public class UserDrop : Drop
{
private readonly User _user;
public string Name
{
get { return _user.Name; }
}
public UserDrop(User user)
{
_user = user;
}
}
Template template = Template.Parse("Name: {{ user.name }}; Email: {{ user.email }};");
string result = template.Render(Hash.FromAnonymousObject(new
{
user = new UserDrop(new User
{
Name = "Tim",
Email = "me@mydomain.com"
})
}));
Therefore, when I pass a DataRow to a liquid, the liquid will not allow me to show its contents and tells me that:
'System.Data.DataRow' is invalid because it is not a built-in type and does not implement ILiquidizable
Are there any solutions for passing a DataRow object that also implements ILiquidizable? Thanks