Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Is THIS the lib to use? #6

Open
lorddev opened this issue Apr 12, 2013 · 3 comments
Open

Question: Is THIS the lib to use? #6

lorddev opened this issue Apr 12, 2013 · 3 comments

Comments

@lorddev
Copy link

lorddev commented Apr 12, 2013

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?

@volkovku
Copy link
Owner

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.

@Eibwen
Copy link

Eibwen commented Nov 19, 2014

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.

@JasonFoglia
Copy link

@Eibwen check out my question here:

#14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants