Click or drag to resize
HelpersHtmlRenderAction Method
Invokes the child action method using the specified parameters and renders the result inline in the parent view.

Namespace: HandlebarsDotNet.Mvc
Assembly: HandlebarsDotNet.Mvc (in HandlebarsDotNet.Mvc.dll) Version: 1.0.0-beta
Syntax
public static void HtmlRenderAction(
	TextWriter writer,
	Object context,
	params Object[] arguments
)

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:
C#
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.
view.hbs
Intro text<br />
{{html_renderaction "Details" "Widget" id="SupDup"}}
WidgetController.cs
public WidgetController
{
    public ActionResult Details(string id)
    {
        var model = new WidgetModel
        {
            Id = id,
            Description = "Super duper widget!"
        };
        return PartialView(model);
    }
}
Details.cshtml
@model WidgetModel
<p>Id: @Model.Id</p>
<p>@Model.Description</p>
Renders
Intro text<br />
<p>Id: SupDup</p>
<p>Super duper widget!</p>
See Also