RazorTemplates icon indicating copy to clipboard operation
RazorTemplates copied to clipboard

Question: Is THIS the lib to use?

Open lorddev opened this issue 12 years ago • 3 comments

I found this on StackOverflow, and I had found RazorEngine as well. However, it seems RazorEngine hasn't been updated in about 2 years, which makes it older than MVC 4, which doesn't seem like a good time. This library, however, has been updated in recent months. So is this the better one to use?

lorddev avatar Apr 12 '13 18:04 lorddev

Hi, Aaron! RazorTemplates like a RazorEngine is a simple wrapper to Razor View Engine 2.0. The common difference is in API. In my opinion RazorTemplates API is more robust then RazorEngine API. You can manage compiled templates as you want. See examples and you can feel difference. But RazorTemplates has a weaknesses. It's very simple wrapper, and does not in the box features like HtmlHelper. I use it in my projects for localize strings, for email and notifications templating, and it's work fine. If you want but not found some features in RazorTemplates you can write me and a I can implement it.

volkovku avatar Apr 13 '13 05:04 volkovku

Hello @volkovku, I'm having trouble getting RazorEngine to work with external assemblies (for example I was using JsonConvert and StructureMap). Would RazorTemplates be able to reference assemblies?

This does seem to work (in both RazorTemplates and RazorEngine)... but is there any simpler way?

public static void TemplateWithThirdPartyNamespaces()
{
    JsonConvert.SerializeObject(new object { }); //Fake usage or external reference in the code just before Parsing the template
    var template = Template
        .WithBaseType<TemplateBase>()
        .AddNamespace("Newtonsoft.Json")
        .Compile(@"In json this is @JsonConvert.SerializeObject(Model)");

    Console.WriteLine(template.Render(new { Apples = 6, Oranges = 5 }));
}

Or anybody know how to do this with any similar project? Thought I would throw this question out there because it doesn't seem to be addressed for any project similar to yours or razor engine.

Eibwen avatar Nov 19 '14 00:11 Eibwen

@Eibwen check out my question here:

https://github.com/volkovku/RazorTemplates/issues/14

JasonFoglia avatar Dec 05 '14 19:12 JasonFoglia