 | HandlebarsViewSetupContext Method |
Creates the context (Handlebars lingo for the model) and stores references to the ViewData and ViewContext.
Namespace: HandlebarsDotNet.MvcAssembly: HandlebarsDotNet.Mvc (in HandlebarsDotNet.Mvc.dll) Version: 1.0.0-beta
Syntaxprotected virtual Object SetupContext(
ViewContext viewContext
)
Protected Overridable Function SetupContext (
viewContext As ViewContext
) As Object
protected:
virtual Object^ SetupContext(
ViewContext^ viewContext
)
abstract SetupContext :
viewContext : ViewContext -> Object
override SetupContext :
viewContext : ViewContext -> Object
Parameters
- viewContext
- Type: ViewContext
The ViewContext that contains the model.
Return Value
Type:
ObjectA newly created context that will be used as the model for views and layouts in HandlebarsDotNet.
Remarks
This method constructs a context object from
viewContext.ViewData.Model.
The context will have a few extra properties added and those are:
"viewbag" - so a view file can use
{{viewbag.title}} for example to output a
ViewBag.Title property that was set in the controller,
and the other one is named in an obscure way (to minimize name clash with user properties) and contains the
ViewContext that was passed to this method.
Helpers may need to get ahold of the ViewContext and in those cases they can use the
HandlebarsView.GetViewContext() static method.
See Also