All data and objects made available to templates are done so using arguments. There are a number of different layers in which arguments can be defined, each shadowing the outer scope as it gets closer to the call-site where the argument is accessed, behaving similarly to properties defined in a JavaScript prototype chain.

TemplateContext Arguments

Essentially this can be thought of as where global variables are maintained, anything defined here is available to every template, partial, filter, etc:

var context = new TemplateContext { 
    Args = {
        ["arg"] = 1

Page Arguments

All pages can define their own arguments within the header of each page, for .html files they are defined within HTML Comments <!-- --> with each argument on a new line delimited by a colon, e.g:


As we can see above, arguments defined in the page take precedence over arguments defined in the layout or context.

PageResult Arguments

Arguments can also be defined in the PageResult context that renders the page, this takes precedence over the above:

var context = new PageResult(context.GetPage("page")) { 
    Args = {
        ["arg"] = 4

Scoped Arguments

Each template can also create their own arguments using the assignTo or assign filters, e.g:


These take precedence over all other arguments, but are only available within the scope that defines them.

made with by ServiceStack