This is a mirror of official site: http://jasper-net.blogspot.com/

Making your own ViewEngine with Markdown

| Thursday, December 2, 2010
Recently I was thinking about integrating the new Razor Templating Engine into MVC so that I could learn how to create my own ViewEngine for MVC. However, I couldn’t quite figure out exactly how to use it in anyway that would make it different from Razor itself. Instead I decided to use Markdown as I frequent Stackoverflow.com quite a bit to try and help with questions related to Razor. (And get some answers for myself) It seemed like a good direction to go. Markdown is probably not a good idea though to use as a view in general. Markdown First things first, I needed a Markdown parser for c#. Luckily Wumpus1 already created a markdownsharp library available on Google Code. Markdown, somewhat, makes sense as a good sample as it’s intended to take text, translate it to html, and display to the end user. It’s also meant to be read without any translation…so this might work for some sort of user input where the end user doesn’t need to know some complex markup language such as wikicode. I’ve added a list of locations to search by default to the MarkdownViewEngine. The ViewEngine public class MarkdownViewEngine : IViewEngine { #region IViewEngine Members string[] SearchLocations; ViewEngineResult FindPartialView( ControllerContext controllerContext, string partialViewName, bool useCache) { } ViewEngineResult FindView( ControllerContext controllerContext, string viewName, string masterName, bool useCache) { } void ReleaseView(ControllerContext controllerContext, IView view) { } Read more: BuildStarted.com

Posted via email from .NET Info

0 comments: