I noticed the ScriptContexts Args property does not have a public setter and I was wondering why? I ask because my use case is at run-time I will be passing in a Dictionary<string, object> into a template and I don’t want the user to have to provide {{arg.property}} in their template, but rather just {{property}}. I believe that would be achievable if I could set the property to my dictionary.
ScriptContext.Args
contains the global arguments for all Scripts which is populated with a number of defaults, it should never be unset, or overridden. If you already have a dictionary of args just copy all the entries into the Args
dictionary, e.g:
foreach (var entry in myArgs)
context.Args[entry.Key] = entry.Value;
After further review of the documentation, I think the Model property on the PageResult would be the better location for my object. I did a test and it works exactly how I want it to. Thanks for making such an awesome tool!
1 Like