protected void RenderFromTemplate(String templateName, Controller controller)
{
StringWriter writer = new StringWriter();
IDictionary context = new Hashtable();
context.Add("flash", controller.Context.Flash);
foreach(DictionaryEntry entry in controller.PropertyBag)
{
context.Add(entry.Key, entry.Value);
}
#if USE_LOCAL_TEMPLATES
templateEngine.Process( context, templateName, writer );
#else
templateEngine.Process( context, "Castle.MonoRail.ActiveRecordScaffold/Templates/" + templateName, writer );
#endif
if (useDefaultLayout)
{
StringWriter layoutwriter = new StringWriter();
context.Add("childContent", writer.GetStringBuilder().ToString());
#if USE_LOCAL_TEMPLATES
templateEngine.Process(context, "layout.vm", layoutwriter);
#else
templateEngine.Process(context, "Castle.MonoRail.ActiveRecordScaffold/Templates/layout.vm", layoutwriter);
#endif
writer = layoutwriter;
controller.CancelView();
controller.Response.Write(writer.GetStringBuilder().ToString());
}
else
{
controller.DirectRender(writer.GetStringBuilder().ToString());
}
}