public void CanBundleJavascriptWithArbitraryCoffeeScript()
        {
            var coffee = "alert 'test' ";

            var tag = javaScriptBundleFactory
                      .WithDebuggingEnabled(false)
                      .Create()
                      .WithPreprocessor(new CoffeeScriptPreprocessor())
                      .AddString(coffee, ".coffee")
                      .Render("~/brewed.js");

            var compiled = javaScriptBundleFactory.FileWriterFactory.Files[TestUtilities.PrepareRelativePath(@"brewed.js")];

            Assert.AreEqual(@"(function(){alert(""test"")}).call(this)", compiled);
            Assert.AreEqual(@"<script type=""text/javascript"" src=""brewed.js?r=hash""></script>", tag);
        }
Beispiel #2
0
        public void CanBundleJavascriptInDebugWithArbitraryHogan()
        {
            const string template = "<h1>{{message}}</h1>";

            var tag = javaScriptBundleFactory
                      .WithDebuggingEnabled(true)
                      .Create()
                      .WithPreprocessor(new HoganPreprocessor())
                      .AddString(template, ".hogan.html")
                      .Render("~/template.js");

            var sb = new StringBuilder();

            sb.AppendLine(@"<script type=""text/javascript"">var JST = JST || {};");
            sb.AppendLine(@"JST['dummy'] = new Hogan.Template(function(c,p,i){var _=this;_.b(i=i||"""");_.b(""<h1>"");_.b(_.v(_.f(""message"",c,p,0)));_.b(""</h1>"");return _.fl();;});");
            sb.AppendLine("</script>");
            Assert.AreEqual(sb.ToString(), tag);
        }