/// <summary> /// Generates an opening script tag. Can be used within a "using" block and the tag will auto-close. /// </summary> /// <param name="helper">The HTML helper instance that this method extends.</param> /// <param name="defer">Whether or not to defer script execution until after page load completion.</param> /// <returns></returns> public static TagBlock BeginJSBlock(this HtmlHelper helper, bool defer) { var tag = new TagBlock(helper.ViewContext, "script"); tag.AddAttribute("type", "text/javascript"); if (defer) { tag.AddAttribute("defer", "defer"); } tag.OpenBlock(); return(tag); }
/// <summary> /// Writes out an opening style tag for inline Css. Can be used within a using() block for auto-close closure. /// </summary> /// <param name="helper">The HTML helper instance that this method extends.</param> /// <param name="media">Css media type.</param> /// <returns></returns> public static TagBlock BeginCssBlock(this HtmlHelper helper, string media) { var tag = new TagBlock(helper.ViewContext, "style"); tag.AddAttribute("type", "text/css"); if (media != null) { tag.AddAttribute("media", media); } tag.AddAttribute("type", "text/css"); tag.OpenBlock(); return(tag); }