mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Adding custom Capture helpers in base views
Usage:
@using(Capture(html => Layout.Content.Add(x))) {
<div>foo</div>
}
And
@using(Capture(Layout.Content)) {
<div>foo</div>
}
--HG--
branch : 1.x
This commit is contained in:
@@ -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<IHtmlString> _callback;
|
||||
|
||||
@@ -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<IHtmlString> _callback;
|
||||
|
||||
Reference in New Issue
Block a user