 | HelpersHtmlRenderAction Method |
Invokes the child action method using the specified parameters and renders the result inline in the parent view.
Namespace: HandlebarsDotNet.MvcAssembly: HandlebarsDotNet.Mvc (in HandlebarsDotNet.Mvc.dll) Version: 1.0.0-beta
Syntaxpublic static void HtmlRenderAction(
TextWriter writer,
Object context,
params Object[] arguments
)
Public Shared Sub HtmlRenderAction (
writer As TextWriter,
context As Object,
ParamArray arguments As Object()
)
public:
static void HtmlRenderAction(
TextWriter^ writer,
Object^ context,
... array<Object^>^ arguments
)
static member HtmlRenderAction :
writer : TextWriter *
context : Object *
arguments : Object[] -> unit
Parameters
- writer
- Type: System.IOTextWriter
The TextWriter provided by HandlebarsDotNet - context
- Type: SystemObject
The context (model) provided by HandlebarsDotNet - arguments
- Type: SystemObject
The arguments from the view, provided by HandlebarsDotNet
Remarks
This helper is among the ones registered if
RegisterMvcHelpers is called. If so, it is registered as
html_renderaction but you can choose your own name for this:
var hbsve = new HandlebarsViewEngine();
hbsve.RegisterHelper("html_renderaction", HandlebarsDotNet.Mvc.Helpers.HtmlRenderAction);
It works like
https://msdn.microsoft.com/en-us/library/system.web.mvc.html.childactionextensions.renderaction.aspx.
Usage
{{html_renderaction [action] [controller] [key=value ...]}}Arguments
- action
- string (required) - The name of the action.
- controller
- string (required) - The name of the controller (without "Controller").
- attributes
- (optional) - The rest of the attributes are used as route values.
Description
The output is rendered with HandlebarsDotNet's WriteSafeString() meaning that using the triple-mustache is not needed.
Examples
This example assumes this helper has been registered as "html_renderaction". Please note that the child action doesn't have to use the same view engine.
Intro text<br />
{{html_renderaction "Details" "Widget" id="SupDup"}}
public WidgetController
{
public ActionResult Details(string id)
{
var model = new WidgetModel
{
Id = id,
Description = "Super duper widget!"
};
return PartialView(model);
}
}
@model WidgetModel
<p>Id: @Model.Id</p>
<p>@Model.Description</p>
Intro text<br />
<p>Id: SupDup</p>
<p>Super duper widget!</p>
See Also