public string GetClientTemplates(JqTemplateCompiler compiler) { var result = new StringBuilder(); foreach (var template in getTemplates()) { // only for jqTmpl for now result.AppendFormat("jQuery.template('{0}', {1});{2}", template.Key, compiler.GetCompiledCode(template.Value), Environment.NewLine); } return(result.ToString()); }
public string GetData(HttpContext context) { var namespaces = BaseNamespace.Split('.'); var builder = new StringBuilder(); var content = string.Empty; for (var index = 1; index <= namespaces.Length; index++) { var ns = string.Join(".", namespaces, 0, index); builder.AppendFormat("if (typeof({0})==='undefined'){{{0} = {{}};}} ", ns); } var store = GetClientVariables(context); if (store != null) { var compiler = new JqTemplateCompiler(); foreach (var clientObject in store) { var resourceSet = clientObject.Value as ClinetResourceSet; if (resourceSet != null) { builder.AppendFormat("{0}.{1}={2};", BaseNamespace, clientObject.Key, JsonConvert.SerializeObject(resourceSet.GetResources())); continue; } var templateSet = clientObject.Value as ClientTemplateSet; if (templateSet != null) { builder.AppendFormat("{0}{1}", Environment.NewLine, templateSet.GetClientTemplates(compiler)); continue; } builder.AppendFormat("{0}.{1}={2};", BaseNamespace, clientObject.Key, JsonConvert.SerializeObject(clientObject.Value)); } content = builder.ToString(); } return(content); }