From 68cf5054263609a48367154576da3d1550236fc4 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Fri, 19 Apr 2013 10:50:17 -0700 Subject: [PATCH] Adding custom Capture helpers in base views Usage: @using(Capture(html => Layout.Content.Add(x))) {
foo
} And @using(Capture(Layout.Content)) {
foo
} --HG-- branch : 1.x --- src/Orchard/Mvc/ViewEngines/Razor/WebViewPage.cs | 4 ++++ src/Orchard/Mvc/ViewPage.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Orchard/Mvc/ViewEngines/Razor/WebViewPage.cs b/src/Orchard/Mvc/ViewEngines/Razor/WebViewPage.cs index d372ff795..0f8245098 100644 --- a/src/Orchard/Mvc/ViewEngines/Razor/WebViewPage.cs +++ b/src/Orchard/Mvc/ViewEngines/Razor/WebViewPage.cs @@ -175,6 +175,10 @@ namespace Orchard.Mvc.ViewEngines.Razor { return new CaptureScope(this, callback); } + public IDisposable Capture(dynamic zone, string position = null) { + return new CaptureScope(this, html => zone.Add(html, position)); + } + class CaptureScope : IDisposable { readonly WebPageBase _viewPage; readonly Action _callback; diff --git a/src/Orchard/Mvc/ViewPage.cs b/src/Orchard/Mvc/ViewPage.cs index 88a876f6f..fe2b42a4b 100644 --- a/src/Orchard/Mvc/ViewPage.cs +++ b/src/Orchard/Mvc/ViewPage.cs @@ -121,6 +121,10 @@ namespace Orchard.Mvc { return new CaptureScope(Writer, callback); } + public IDisposable Capture(dynamic zone, string position = null) { + return new CaptureScope(Writer, html => zone.Add(html, position)); + } + public class CaptureScope : IDisposable { private readonly HtmlTextWriter _context; private readonly Action _callback;