Mercurial > pub > RazorEngine
comparison src/Web/RazorEngine.Mvc/MvcTemplateBase.cs @ 0:5bca2d201ad8
initial commit
| author | cin |
|---|---|
| date | Sun, 24 Aug 2014 11:14:55 +0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:5bca2d201ad8 |
|---|---|
| 1 namespace RazorEngine.Mvc | |
| 2 { | |
| 3 using System; | |
| 4 using System.Web; | |
| 5 using System.Web.Mvc; | |
| 6 | |
| 7 using Templating; | |
| 8 | |
| 9 /// <summary> | |
| 10 /// Provides a base implementation of an MVC-compatible template. | |
| 11 /// </summary> | |
| 12 public abstract class MvcTemplateBase : TemplateBase | |
| 13 { | |
| 14 #region Properties | |
| 15 /// <summary> | |
| 16 /// Gets the <see cref="HtmlHelper{Object}"/> for this template. | |
| 17 /// </summary> | |
| 18 public HtmlHelper<object> Html { get; private set; } | |
| 19 | |
| 20 /// <summary> | |
| 21 /// Gets the <see cref="UrlHelper"/> for this template. | |
| 22 /// </summary> | |
| 23 public UrlHelper Url { get; private set; } | |
| 24 #endregion | |
| 25 | |
| 26 #region Methods | |
| 27 public void InitHelpers() | |
| 28 { | |
| 29 var httpContext = new HttpContextWrapper(HttpContext.Current); | |
| 30 var handler = httpContext.CurrentHandler as MvcHandler; | |
| 31 if (handler == null) | |
| 32 throw new InvalidOperationException("Unable to run template outside of ASP.NET MVC"); | |
| 33 } | |
| 34 #endregion | |
| 35 } | |
| 36 } |
