public IClientModel BeginIterate(IClientModel model) { //var itemIdx = model.ToString().Split("item").Length; var jsModel = model as JavascriptClientModel; var itemVariable = new JavascriptClientModel(model as JavascriptClientModel, "item" + jsModel.Depth); _writer.Write("for (var i{2} = 0; i{2} < {1}.length; i{2}++){{ var {0} = {1}[i{2}]; ", itemVariable, model, jsModel.Depth); return itemVariable; }
public IClientModel BeginIterate(IClientModel model) { //var itemIdx = model.ToString().Split("item").Length; var jsModel = model as JavascriptClientModel; var itemVariable = new JavascriptClientModel(model as JavascriptClientModel, "item" + jsModel.Depth); _writer.Write("for (var i{2} = 0; i{2} < {1}.length; i{2}++){{ var {0} = {1}[i{2}]; ", itemVariable, model, jsModel.Depth); return(itemVariable); }
public string Generate(TemplateInfo templateInfo) { var builder = new StringBuilder(); using (var writer = new StringWriter(builder)) { writer.Write("{0}.register(\"{1}\", {{ render: function(ctx, model) {{ var w = function(v) {{ ctx.write(v); }}; var we = function(v) {{ ctx.writeEscape(v); }};", _templateRepository, templateInfo.Id); var clientContext = new JavascriptClientContext(templateInfo.Id, writer); var model = new JavascriptClientModel(null, "model"); _templateGenerator.Generate(templateInfo, clientContext, model); writer.Write("}});"); } return builder.ToString(); }
public string Generate(TemplateInfo templateInfo) { var builder = new StringBuilder(); using (var writer = new StringWriter(builder)) { writer.Write("{0}.register(\"{1}\", {{ render: function(ctx, model) {{ var w = function(v) {{ ctx.write(v); }}; var we = function(v) {{ ctx.writeEscape(v); }};", _templateRepository, templateInfo.Id); var clientContext = new JavascriptClientContext(templateInfo.Id, writer); var model = new JavascriptClientModel(null, "model"); _templateGenerator.Generate(templateInfo, clientContext, model); writer.Write("}});"); } return(builder.ToString()); }
public JavascriptClientModel(JavascriptClientModel parent, string variableName) { Parent = parent; _variableName = variableName; }
public JavascriptClientModel(JavascriptClientModel parent, string variableName) { Parent = parent; _variableName = variableName; }