public void Process(BundleContext context, BundleResponse response)
        {
            var compiler  = new HandlebarsCompiler();
            var templates = new Dictionary <string, string>();
            var server    = context.HttpContext.Server;

            foreach (var bundleFile in response.Files)
            {
                var filePath           = server.MapPath(bundleFile.VirtualFile.VirtualPath);
                var bundleRelativePath = GetRelativePath(server, bundleFile, filePath);
                var templateName       = namer.GenerateName(bundleRelativePath, bundleFile.VirtualFile.Name);
                var template           = File.ReadAllText(filePath);
                var compiled           = compiler.Precompile(template, false);

                templates[templateName] = compiled;
            }
            StringBuilder javascript = new StringBuilder();

            foreach (var templateName in templates.Keys)
            {
                javascript.AppendFormat("Ember.TEMPLATES['{0}']=", templateName);
                javascript.AppendFormat("Ember.Handlebars.template({0});", templates[templateName]);
            }

            var Compressor = new JavaScriptCompressor();
            var compressed = Compressor.Compress(javascript.ToString());

            response.ContentType  = "text/javascript";
            response.Cacheability = HttpCacheability.Public;
            response.Content      = compressed;
        }
 private static IHtmlString BuildTemplates(string templatePath, List<string> files, ITemplateNamer templateNamer)
 {
     var templates = new StringBuilder();
     foreach (var templateFile in files)
     {
         var pathDiff = FileToolkit.PathDifference(templateFile, templatePath);
         var templateName = templateNamer.GenerateName(pathDiff, Path.GetFileName(templateFile));
         templates.AppendFormat("<script type='text/x-handlebars' data-template-name='{0}'>\n", templateName);
         templates.AppendLine(File.ReadAllText(templateFile));
         templates.AppendLine("</script>");
     }
     return new HtmlString(templates.ToString());
 }
        private static IHtmlString BuildTemplates(string templatePath, List <string> files, ITemplateNamer templateNamer)
        {
            var templates = new StringBuilder();

            foreach (var templateFile in files)
            {
                var pathDiff     = FileToolkit.PathDifference(templateFile, templatePath);
                var templateName = templateNamer.GenerateName(pathDiff, Path.GetFileName(templateFile));
                templates.AppendFormat("<script type='text/x-handlebars' data-template-name='{0}'>\n", templateName);
                templates.AppendLine(File.ReadAllText(templateFile));
                templates.AppendLine("</script>");
            }
            return(new HtmlString(templates.ToString()));
        }