using System.IO;
using RazorEngine;
namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
const string markup = "@{ Layout = null; } @model dynamic <!DOCTYPE html> <html> <head> <title>Tatooine</title> </head> <body> <div> These are not the @Model.Name you are looking for.</div> </body> </html>";
Engine.Razor.RunCompile(markup, "Tatooine", TextWriter.Null, new Form() { Name = "droids" });
}
}
public class Form
{
public string Name;
}
}
using RazorEngine.Templating
was removed by Resharper ...
Error 1 The best overloaded method match for 'RazorEngine.Templating.IRazorEngineService.RunCompile(RazorEngine.Templating.ITemplateKey, System.IO.TextWriter, System.Type, object, RazorEngine.Templating.DynamicViewBag)' has some invalid arguments
Engine.Razor.RunCompile(markup, "Tatooine", TextWriter.Null, model: new Form() { Name = "droids" });
(without specifying the modelType
parameter which is always there and before the model
parameter)
null
: Engine.Razor.RunCompile(markup, "Tatooine", TextWriter.Null, null, new Form() { Name = "droids" });
(the last two are basically the same thing)
ITemplateKey
overload...
It should actually be quite easy to see (even while debugging) if caching is in place. First its just very slow when everything is compiled, and second you can see a "csc.exe" in task manager whenever a template is compiled (which should be the one time only for every template)
Does this answer your question?