public void Process(BundleContext context, BundleResponse response)
        {
            var builder = new Ember.Handlebars.TemplateBuilder();
            var usTextInfo = new CultureInfo("en-US", false).TextInfo;

            foreach (var assetFile in response.Files)
            {
                var template = File.ReadAllText(assetFile.FullName);
                var templateName = Path.GetFileNameWithoutExtension(assetFile.FullName).ToCamelCase();
                builder.Register(templateName, template);
            }

            response.Content = builder.ToString();
            response.ContentType = "text/javascript";
            response.Cacheability = HttpCacheability.Public;
        }
        public void Process(BundleContext context, BundleResponse response)
        {
            var builder = new Ember.Handlebars.TemplateBuilder();
            var usTextInfo = new CultureInfo("en-US", false).TextInfo;

            foreach (var assetFile in response.Files)
            {
                var path = context.HttpContext.Server.MapPath(assetFile.VirtualFile.VirtualPath.Replace("/", "\\"));
                var template = File.ReadAllText(path);
                var templateName = Path.GetFileNameWithoutExtension(path).Replace("-", "/");
                builder.Register(templateName, template);
            }

            response.Content = builder.ToString();
            response.ContentType = "text/javascript";
            response.Cacheability = HttpCacheability.Public;
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var builder = new Ember.Handlebars.TemplateBuilder();
            builder.Register("application", "<h1>{{App.name}}</h1>");

            Console.WriteLine(builder.ToString());
            // returns =>
            //
            // Ember.TEMPLATES["application"] = Ember.Handlebars.template(function anonymous(Handlebars, depth0, helpers, partials, data) {
            //     helpers = helpers || Ember.Handlebars.helpers; data = data || {};
            //     var buffer = '', stack1, escapeExpression=this.escapeExpression;
            //     data.buffer.push("<h1>");
            //     stack1 = helpers._triageMustache.call(depth0, "App.name", {hash:{},contexts:[depth0],data:data});
            //     data.buffer.push(escapeExpression(stack1) + "</h1>");
            //     return buffer;
            // });

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }