public string CreateFunctionScriptBlock(StreamReader reader, string partialViewName, string methodName, IServiceProvider provider, ITemplateEngine engine, params String[] parameters) { XmlTextReader xmlReader = new XmlTextReader(reader); xmlReader.Namespaces = false; xmlReader.WhitespaceHandling = WhitespaceHandling.All; DefaultContext context = new DefaultContext(partialViewName, xmlReader, provider, engine); context.Script.Append("def "); context.Script.Append(methodName); context.Script.Append('('); context.Script.Append("controller, context, request, response, session, output, flash, siteroot"); // context.Script.Append("output"); foreach(String param in parameters) { context.Script.Append(','); context.Script.Append(param); } context.Script.Append(')'); context.Script.AppendLine(":"); context.IncreaseIndentation(); // context.AppendLineIndented("print 'hello'"); ProcessReader(context, 0); context.DecreaseIndentation(); context.Script.AppendLine(); return context.Script.ToString(); }
public String CreateScriptBlock(TextReader reader, String viewName, IServiceProvider serviceProvider, ITemplateEngine engine) { XmlTextReader xmlReader = new XmlTextReader(reader); xmlReader.Namespaces = false; xmlReader.WhitespaceHandling = WhitespaceHandling.All; DefaultContext context = new DefaultContext(viewName, xmlReader, serviceProvider, engine); ProcessReader(context, 0); return context.Script.ToString(); }