public void CanIncludeDynamicContentInDebug() { var context = new Mock <HttpContextBase>(); var request = new Mock <HttpRequestBase>(); request.SetupGet(r => r.Url).Returns(new Uri("http://example.com")); context.SetupGet(c => c.Request).Returns(request.Object); using (new HttpContextScope(context.Object)) { javaScriptBundle .ForceDebug() .AddDynamic("/some/dynamic/js"); } var tag = javaScriptBundle .Render("~/combined_#.js"); Assert.AreEqual(0, fileWriterFactory.Files.Count); Assert.AreEqual("<script type=\"text/javascript\" src=\"/some/dynamic/js\"></script>\n", TestUtilities.NormalizeLineEndings(tag)); }
/// <summary> /// Renders current <see cref="JavaScriptBundle" /> to given file /// </summary> /// <param name="javaScriptBundle">Current javascript bundle</param> /// <param name="renderTo">File to render to</param> /// <returns>Current bundle</returns> public static IHtmlString MvcRender(this JavaScriptBundle javaScriptBundle, string renderTo) { return(new NonEncodedHtmlString(javaScriptBundle.Render(renderTo))); }
public static MvcHtmlString MvcRender(this JavaScriptBundle javaScriptBundle, string renderTo) { return(MvcHtmlString.Create(javaScriptBundle.Render(renderTo))); }