Arguments
All data and objects made available to scripts 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.
ScriptContext Arguments
Essentially this can be thought of as where global variables are maintained, anything defined here is available to every page, partial, method, block, etc:
var context = new ScriptContext {
Args = {
["arg"] = 1
}
}.Init();
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 an (optional) colon, e.g:
_layout.html
page.html
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:
_layout.html
page.html
These take precedence over all other arguments, but are only available within the scope that defines them.