Mercurial > pub > RazorEngine
diff src/Web/RazorEngine.Mvc/MvcTemplateBase.cs @ 0:5bca2d201ad8
initial commit
author | cin |
---|---|
date | Sun, 24 Aug 2014 11:14:55 +0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Web/RazorEngine.Mvc/MvcTemplateBase.cs Sun Aug 24 11:14:55 2014 +0400 @@ -0,0 +1,36 @@ +namespace RazorEngine.Mvc +{ + using System; + using System.Web; + using System.Web.Mvc; + + using Templating; + + /// <summary> + /// Provides a base implementation of an MVC-compatible template. + /// </summary> + public abstract class MvcTemplateBase : TemplateBase + { + #region Properties + /// <summary> + /// Gets the <see cref="HtmlHelper{Object}"/> for this template. + /// </summary> + public HtmlHelper<object> Html { get; private set; } + + /// <summary> + /// Gets the <see cref="UrlHelper"/> for this template. + /// </summary> + public UrlHelper Url { get; private set; } + #endregion + + #region Methods + public void InitHelpers() + { + var httpContext = new HttpContextWrapper(HttpContext.Current); + var handler = httpContext.CurrentHandler as MvcHandler; + if (handler == null) + throw new InvalidOperationException("Unable to run template outside of ASP.NET MVC"); + } + #endregion + } +} \ No newline at end of file