0

I want to refactor an existing MVC action so that it can be used offline to build email content.

The action just fetches a model by Id and hands it over to the view, where the view renders it's fields. There is a foreach loop in the view.

My first thought was to just create an html file and do string search and replace in it.

Is there any template rendering libraries I should consider instead?

Carl R
  • 8,104
  • 5
  • 48
  • 80
  • possible dublicate http://stackoverflow.com/questions/13035427/razorgenerator-templates-and-html – Kirill Bestemyanov Dec 03 '12 at 10:58
  • what you mean by offline? ControllerContext is not available? – VJAI Dec 03 '12 at 15:08
  • @Mark Yes, I mean outside the controller. Could for instance be from a separate thread or from a SignalR endpoint. Maybe even from a windows service or a scheduled exe file. – Carl R Dec 04 '12 at 08:08

1 Answers1

2

You may take a look at RazorEngine.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • The project is currently using MVC2. Would that cause conflicts with RazorEngine? – Carl R Dec 03 '12 at 12:17
  • I see, you should have mentioned that as part of your question. The RazorEngine project is using the Razor engine which works with ASP.NET MVC 3. – Darin Dimitrov Dec 03 '12 at 12:21