// ENDSAMPLE // SAMPLE: embed-file /// <summary> /// Embed the contents of an entire code file into a FubuMVC view /// </summary> /// <param name="page"></param> /// <param name="fileName">The name of the file relative to the root of the web application or Bottle</param> /// <param name="languageClass">Optional. Overrides the lang-* class on the element for prettify.css formatting</param> /// <param name="levelIndentation">Not yet used. Will force the display to remove extra indentation for deeply nested code</param> /// <returns></returns> public static HtmlTag CodeFile(this IFubuPage page, string fileName, string languageClass = null, bool levelIndentation = false) { var formatter = new CodeFormatter(levelIndentation); var file = page.Get<IFubuApplicationFiles>().Find(fileName); if (file == null) { return new HtmlTag("p").Text("Could not find file " + fileName); } var snippet = formatter.Format(file); return page.CodeSnippet(snippet); }
/// <summary> /// Embed a named code snippet into a FubuMVC view /// </summary> /// <param name="page"></param> /// <param name="snippetName"></param> /// <returns></returns> public static HtmlTag CodeSnippet(this IFubuPage page, string snippetName) { var snippet = page.Get<ISnippetCache>().Find(snippetName); return page.CodeSnippet(snippet); }