private NHamlMonoRailView GetTemplate(IControllerContext controllerContext, IList <string> sources) { foreach (var abstractHelper in controllerContext.Helpers.Values) { TemplateEngine.Options.AddReferences(abstractHelper.GetType()); } var templateBuilderContext = new TemplateBuilderContext(); foreach (var key in controllerContext.Helpers.Keys) { templateBuilderContext.Helpers.Add((string)key, controllerContext.Helpers[key].GetType()); Debug.WriteLine(key); } var compiledTemplate = TemplateEngine.Compile(TemplateEngine.Options.TemplateBaseType, TemplateEngine.ConvertPathsToViewSources(sources), templateBuilderContext); var template = (NHamlMonoRailView)compiledTemplate.CreateInstance(); template.ViewEngine = this; var tempalteType = template.GetType(); foreach (var key in controllerContext.Helpers.Keys) { var property = tempalteType.GetField((string)key); var value = controllerContext.Helpers[key]; property.SetValue(template, value); } return(template); }